mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
trie: close temporary databases in GetDB benchmark
This commit is contained in:
parent
bfe3da83e2
commit
2819f1c324
1 changed files with 8 additions and 2 deletions
|
|
@ -460,8 +460,7 @@ const benchElemCount = 20000
|
||||||
func benchGet(b *testing.B, commit bool) {
|
func benchGet(b *testing.B, commit bool) {
|
||||||
trie := new(Trie)
|
trie := new(Trie)
|
||||||
if commit {
|
if commit {
|
||||||
dir, tmpdb := tempDB()
|
_, tmpdb := tempDB()
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
trie, _ = New(common.Hash{}, tmpdb)
|
trie, _ = New(common.Hash{}, tmpdb)
|
||||||
}
|
}
|
||||||
k := make([]byte, 32)
|
k := make([]byte, 32)
|
||||||
|
|
@ -478,6 +477,13 @@ func benchGet(b *testing.B, commit bool) {
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
trie.Get(k)
|
trie.Get(k)
|
||||||
}
|
}
|
||||||
|
b.StopTimer()
|
||||||
|
|
||||||
|
if commit {
|
||||||
|
ldb := trie.db.(*ethdb.LDBDatabase)
|
||||||
|
ldb.Close()
|
||||||
|
os.RemoveAll(ldb.Path())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func benchUpdate(b *testing.B, e binary.ByteOrder) *Trie {
|
func benchUpdate(b *testing.B, e binary.ByteOrder) *Trie {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue