1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builtin,strconv: speedup str.int() conversions (without -prod)

This commit is contained in:
Delyan Angelov
2022-09-08 11:09:13 +03:00
parent a462610376
commit fc8e3d0971
10 changed files with 63 additions and 30 deletions

View File

@@ -0,0 +1,17 @@
import benchmark
const maxn = 999_999
fn main() {
mut snumbers := []string{cap: maxn}
for i in 0 .. maxn {
snumbers << i.str()
}
mut sum := i64(0)
mut bmark := benchmark.start()
for s in snumbers {
sum += s.int()
}
bmark.measure('s.int()')
dump(sum)
}

View File

@@ -1,3 +1,5 @@
import os
[direct_array_access]
fn test_big_int_array() {
dump(sizeof(isize))
@@ -5,6 +7,11 @@ fn test_big_int_array() {
if sizeof(isize) > 4 {
maxn = 1_000_000_000 // 1 billion integers, when each is 4 bytes => require ~4GB
}
// NB: this test requires RAM that many people do not have, so only run it in full, when VTEST_BIGMEM is 1
vtest_bigmem := os.getenv('VTEST_BIGMEM').int()
if vtest_bigmem == 0 {
maxn = 10_000_000
}
dump(maxn)
mut data := []int{len: maxn}