mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
trie: fix benchget, avoid alloc for key
This commit is contained in:
parent
3ee96b35ad
commit
a37331dcac
1 changed files with 4 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)
|
||||
|
||||
|
|
@ -627,9 +629,9 @@ 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))
|
||||
e.PutUint64(v, uint64(i))
|
||||
|
|
|
|||
Loading…
Reference in a new issue