rollsum: log stats after benchmark run

Change-Id: I2c8983d13ea80efb383ebf77316e6ad0a5da9f57
This commit is contained in:
Brad Fitzpatrick 2012-10-28 13:07:42 +01:00
parent 137528b7d6
commit 82329b5882
1 changed files with 5 additions and 3 deletions

View File

@ -57,15 +57,17 @@ func TestSum(t *testing.T) {
func BenchmarkRollsum(b *testing.B) {
bytesSize := int64(1024 * 1024 * 5)
rs := New()
bits := 0
splits := 0
for i := 0; i < b.N; i++ {
splits = 0
for j := int64(0); j < bytesSize; j++ {
rs.Roll(byte(rand.Int63() & 0xff))
if rs.OnSplit() {
bits = rs.Bits()
_ = rs.Bits()
splits++
}
}
}
b.SetBytes(bytesSize)
_ = bits
b.Logf("num splits = %d; every %d bytes", splits, int(float64(bytesSize) / float64(splits)))
}