mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
improve join benchmarks
This commit is contained in:
parent
b8bd17de28
commit
5e56f338d4
1 changed files with 10 additions and 8 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue