cmd/tools/bench/wyhash.v: use predetermined seed, to ensure comparable results
parent
8dede3b535
commit
df5625bf68
|
@ -6,6 +6,8 @@ import rand
|
||||||
import time
|
import time
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
rand.seed([u32(42), 0])
|
||||||
|
mut aaa := u64(0)
|
||||||
sample_size := 10000000
|
sample_size := 10000000
|
||||||
min_str_len := 20
|
min_str_len := 20
|
||||||
max_str_len := 40
|
max_str_len := 40
|
||||||
|
@ -21,32 +23,38 @@ fn main() {
|
||||||
println('Hashing each of the generated strings...')
|
println('Hashing each of the generated strings...')
|
||||||
t0 := time.ticks()
|
t0 := time.ticks()
|
||||||
mut start_pos := 0
|
mut start_pos := 0
|
||||||
|
aaa = 0
|
||||||
for len in str_lens {
|
for len in str_lens {
|
||||||
end_pos := start_pos + len
|
end_pos := start_pos + len
|
||||||
str := string(bytepile[start_pos..end_pos],len)
|
str := string(bytepile[start_pos..end_pos], len)
|
||||||
wyhash.wyhash_c(&str.str, u64(str.len), 1)
|
aaa ^= wyhash.wyhash_c(&str.str, u64(str.len), 1)
|
||||||
start_pos = end_pos
|
start_pos = end_pos
|
||||||
}
|
}
|
||||||
|
println('aaa: $aaa')
|
||||||
t1 := time.ticks()
|
t1 := time.ticks()
|
||||||
d1 := t1 - t0
|
d1 := t1 - t0
|
||||||
println(' * wyhash4 C: ${d1}ms')
|
println(' * wyhash4 C: ${d1}ms')
|
||||||
start_pos = 0
|
start_pos = 0
|
||||||
|
aaa = 0
|
||||||
for len in str_lens {
|
for len in str_lens {
|
||||||
end_pos := start_pos + len
|
end_pos := start_pos + len
|
||||||
str := string(bytepile[start_pos..end_pos],len)
|
str := string(bytepile[start_pos..end_pos], len)
|
||||||
wyhash.sum64_string(str, 1)
|
aaa ^= wyhash.sum64_string(str, 1)
|
||||||
start_pos = end_pos
|
start_pos = end_pos
|
||||||
}
|
}
|
||||||
|
println('aaa: $aaa')
|
||||||
t2 := time.ticks()
|
t2 := time.ticks()
|
||||||
d2 := t2 - t1
|
d2 := t2 - t1
|
||||||
println(' * wyhash4: ${d2}ms')
|
println(' * wyhash4: ${d2}ms')
|
||||||
start_pos = 0
|
start_pos = 0
|
||||||
|
aaa = 0
|
||||||
for len in str_lens {
|
for len in str_lens {
|
||||||
end_pos := start_pos + len
|
end_pos := start_pos + len
|
||||||
str := string(bytepile[start_pos..end_pos],len)
|
str := string(bytepile[start_pos..end_pos], len)
|
||||||
fnv1a.sum64_string(str)
|
aaa ^= fnv1a.sum64_string(str)
|
||||||
start_pos = end_pos
|
start_pos = end_pos
|
||||||
}
|
}
|
||||||
|
println('aaa: $aaa')
|
||||||
t3 := time.ticks()
|
t3 := time.ticks()
|
||||||
d3 := t3 - t2
|
d3 := t3 - t2
|
||||||
println(' * fnv1a64: ${d3}ms')
|
println(' * fnv1a64: ${d3}ms')
|
||||||
|
|
Loading…
Reference in New Issue