mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
triedb/pathdb: add benchmark test
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
e94123acc2
commit
e44cc0654f
1 changed files with 18 additions and 0 deletions
|
|
@ -214,3 +214,21 @@ func TestCorruptedIndexBlock(t *testing.T) {
|
|||
t.Fatal("Corrupted index block data is not detected")
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkParseIndexBlock benchmarks the performance of parseIndexBlock.
|
||||
func BenchmarkParseIndexBlock(b *testing.B) {
|
||||
// Generate a realistic index block blob
|
||||
bw, _ := newBlockWriter(nil, newIndexBlockDesc(0))
|
||||
for i := 0; i < 4096; i++ {
|
||||
bw.append(uint64(i * 2))
|
||||
}
|
||||
blob := bw.finish()
|
||||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, _, err := parseIndexBlock(blob)
|
||||
if err != nil {
|
||||
b.Fatalf("parseIndexBlock failed: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue