improve join benchmarks

This commit is contained in:
zelig 2015-02-13 13:38:24 +01:00
parent b8bd17de28
commit 5e56f338d4

View file

@ -177,23 +177,25 @@ func readAll(reader SectionReader, result []byte) {
}
}
func benchReadAll(reader SectionReader) {
size := reader.Size()
output := make([]byte, 1000)
for pos := int64(0); pos < size; pos += 1000 {
reader.ReadAt(output, pos)
}
}
func benchmarkJoinRandomData(n int, chunks int, t *testing.B) {
t.StopTimer()
for i := 0; i < t.N; i++ {
// fmt.Printf("round %v\n", i)
chunker, tester := chunkerAndTester()
key, slice := tester.Split(chunker, n)
key, _ := tester.Split(chunker, n)
// fmt.Printf("split done %v, joining...\n", i)
t.StartTimer()
reader := tester.Join(chunker, key, i)
// fmt.Printf("join done %v, reading...\n", i)
result := make([]byte, n)
readAll(reader, result)
// fmt.Printf("read done %v\n", i)
t.StopTimer()
if !bytes.Equal(slice, result) {
t.Errorf("input output mismatch")
}
benchReadAll(reader)
}
}