trie/trie_test: Fix Trie Benchmark Bug: Ensure Key Immutability in geth Benchmarks

This commit is contained in:
DeVil2O 2023-09-28 18:55:48 +05:30
parent b9450bfcca
commit 3ee96b35ad

View file

@ -627,11 +627,13 @@ func benchGet(b *testing.B) {
func benchUpdate(b *testing.B, e binary.ByteOrder) *Trie {
trie := NewEmpty(NewDatabase(rawdb.NewMemoryDatabase(), nil))
k := make([]byte, 32)
b.ReportAllocs()
for i := 0; i < b.N; i++ {
k := make([]byte, 32)
v := make([]byte, 32)
e.PutUint64(k, uint64(i))
trie.MustUpdate(k, k)
e.PutUint64(v, uint64(i))
trie.MustUpdate(k, v)
}
return trie
}