rollsum: add a benchmark, and more attribution

This commit is contained in:
Brad Fitzpatrick 2011-06-06 19:09:58 -07:00
parent 39ac2c072e
commit 1f0aec0612
3 changed files with 20 additions and 1 deletions

View File

@ -1 +1 @@
6g version weekly.2011-06-02 8633+
6g version weekly.2011-05-22 8613+

View File

@ -16,6 +16,9 @@ limitations under the License.
// Package rollsum implements rolling checksums similar to apenwarr's bup, which
// is similar to librsync.
//
// The bup project is at https://github.com/apenwarr/bup and its splitting in
// particular is at https://github.com/apenwarr/bup/blob/master/lib/bup/bupsplit.c
package rollsum
import (

View File

@ -53,3 +53,19 @@ func TestSum(t *testing.T) {
t.Errorf("sum3a=%d sum3b=%d", sum3a, sum3b)
}
}
func BenchmarkRollsum(b *testing.B) {
bytesSize := int64(1024 * 1024 * 5)
rs := New()
bits := 0
for i := 0; i < b.N; i++ {
for j := int64(0); j < bytesSize; j++ {
rs.Roll(byte(rand.Int63() & 0xff))
if rs.OnSplit() {
bits = rs.Bits()
}
}
}
b.SetBytes(bytesSize)
_ = bits
}