trie: close temporary databases in GetDB benchmark

This commit is contained in:
Felix Lange 2016-10-14 03:53:09 +02:00
parent bfe3da83e2
commit 2819f1c324

View file

@ -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 {