Last active
August 29, 2015 14:16
-
-
Save trygenericdev/ca64d83e193bbc2cb3ff to your computer and use it in GitHub Desktop.
BenchmarkRollsum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func BenchmarkRollsum(b *testing.B) { | |
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 _, b := range buf { | |
rs.Roll(b) | |
if rs.OnSplit() { | |
_ = rs.Bits() | |
splits++ | |
} | |
} | |
} | |
b.SetBytes(bufSize) | |
b.Logf("num splits = %d; every %d bytes", splits, int(float64(bufSize)/float64(splits))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment