mirror of https://github.com/perkeep/perkeep.git
rollsum: add a benchmark, and more attribution
This commit is contained in:
parent
39ac2c072e
commit
1f0aec0612
|
@ -1 +1 @@
|
|||
6g version weekly.2011-06-02 8633+
|
||||
6g version weekly.2011-05-22 8613+
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue