mirror of https://github.com/perkeep/perkeep.git
rollsum: don't benchmark the Rand function
Change-Id: Ibed1864d3b4c57eb3684c7208610da7015b6365d
This commit is contained in:
parent
c9bf045aac
commit
1ef4587913
|
@ -55,19 +55,25 @@ func TestSum(t *testing.T) {
|
|||
}
|
||||
|
||||
func BenchmarkRollsum(b *testing.B) {
|
||||
bytesSize := int64(1024 * 1024 * 5)
|
||||
const bufSize = 5 << 20
|
||||
buf := make([]byte, bufSize)
|
||||
for i := range buf {
|
||||
buf[i] = byte(rand.Int63())
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
rs := New()
|
||||
splits := 0
|
||||
for i := 0; i < b.N; i++ {
|
||||
splits = 0
|
||||
for j := int64(0); j < bytesSize; j++ {
|
||||
rs.Roll(byte(rand.Int63() & 0xff))
|
||||
for _, b := range buf {
|
||||
rs.Roll(b)
|
||||
if rs.OnSplit() {
|
||||
_ = rs.Bits()
|
||||
splits++
|
||||
}
|
||||
}
|
||||
}
|
||||
b.SetBytes(bytesSize)
|
||||
b.Logf("num splits = %d; every %d bytes", splits, int(float64(bytesSize)/float64(splits)))
|
||||
b.SetBytes(bufSize)
|
||||
b.Logf("num splits = %d; every %d bytes", splits, int(float64(bufSize)/float64(splits)))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue