From 5e56f338d4eeb1960c9ebf604eeb1e4c864ee1f3 Mon Sep 17 00:00:00 2001 From: zelig Date: Fri, 13 Feb 2015 13:38:24 +0100 Subject: [PATCH] improve join benchmarks --- bzz/chunker_test.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/bzz/chunker_test.go b/bzz/chunker_test.go index 5886dfd6f5..cf0d210571 100644 --- a/bzz/chunker_test.go +++ b/bzz/chunker_test.go @@ -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) } }