Fix get_random for count != 4k, add randomReader()

This commit is contained in:
Alexander Neumann 2015-02-11 17:38:51 +01:00
parent 3bf66d24fa
commit 93abaf204a

View file

@ -16,18 +16,18 @@ var benchArchiveDirectory = flag.String("test.benchdir", "", "benchmark archivin
func get_random(seed, count int) []byte {
buf := make([]byte, count)
rnd := rand.New(rand.NewSource(23))
for i := 0; i < count; i += 4 {
r := rnd.Uint32()
buf[i] = byte(r)
buf[i+1] = byte(r >> 8)
buf[i+2] = byte(r >> 16)
buf[i+3] = byte(r >> 24)
rnd := rand.New(rand.NewSource(int64(seed)))
for i := 0; i < count; i++ {
buf[i] = byte(rnd.Uint32())
}
return buf
}
func randomReader(seed, size int) *bytes.Reader {
return bytes.NewReader(get_random(seed, size))
}
const bufSize = chunker.MiB
func benchmarkChunkEncrypt(b testing.TB, rd interface {