mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 15:47:21 +00:00
trie: fix benchmark by ensuring key immutability (#28221)
This change fixes the bug in a benchmark, where the input to the trie is reused in a way which is not correct. --------- Co-authored-by: Martin Holst Swende <martin@swende.se>
This commit is contained in:
parent
339a4cf056
commit
2091ebdf5e
1 changed files with 6 additions and 2 deletions
|
|
@ -614,7 +614,9 @@ func benchGet(b *testing.B) {
|
|||
k := make([]byte, 32)
|
||||
for i := 0; i < benchElemCount; i++ {
|
||||
binary.LittleEndian.PutUint64(k, uint64(i))
|
||||
trie.MustUpdate(k, k)
|
||||
v := make([]byte, 32)
|
||||
binary.LittleEndian.PutUint64(v, uint64(i))
|
||||
trie.MustUpdate(k, v)
|
||||
}
|
||||
binary.LittleEndian.PutUint64(k, benchElemCount/2)
|
||||
|
||||
|
|
@ -630,8 +632,10 @@ func benchUpdate(b *testing.B, e binary.ByteOrder) *Trie {
|
|||
k := make([]byte, 32)
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
v := make([]byte, 32)
|
||||
e.PutUint64(k, uint64(i))
|
||||
trie.MustUpdate(k, k)
|
||||
e.PutUint64(v, uint64(i))
|
||||
trie.MustUpdate(k, v)
|
||||
}
|
||||
return trie
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue