From 2819f1c32433a4257145b4bb12c9913b08f4169f Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 14 Oct 2016 03:53:09 +0200 Subject: [PATCH] trie: close temporary databases in GetDB benchmark --- trie/trie_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/trie/trie_test.go b/trie/trie_test.go index 87a7ec258d..32fbe6801d 100644 --- a/trie/trie_test.go +++ b/trie/trie_test.go @@ -460,8 +460,7 @@ const benchElemCount = 20000 func benchGet(b *testing.B, commit bool) { trie := new(Trie) if commit { - dir, tmpdb := tempDB() - defer os.RemoveAll(dir) + _, tmpdb := tempDB() trie, _ = New(common.Hash{}, tmpdb) } k := make([]byte, 32) @@ -478,6 +477,13 @@ func benchGet(b *testing.B, commit bool) { for i := 0; i < b.N; i++ { 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 {