OSDN Git Service

bd26fcd4a18974d4cc25a89818d488918bc28e36
[bytom/vapor.git] / test / performance / mining_test.go
1 package performance
2
3 import (
4         "os"
5         "testing"
6
7         "github.com/vapor/account"
8         dbm "github.com/vapor/database/leveldb"
9         "github.com/vapor/mining"
10         "github.com/vapor/test"
11 )
12
13 // Function NewBlockTemplate's benchmark - 0.05s
14 func BenchmarkNewBlockTpl(b *testing.B) {
15         testDB := dbm.NewDB("testdb", "leveldb", "temp")
16         defer os.RemoveAll("temp")
17
18         chain, _, txPool, err := test.MockChain(testDB)
19         if err != nil {
20                 b.Fatal(err)
21         }
22         accountManager := account.NewManager(testDB, chain)
23
24         b.ResetTimer()
25         for i := 0; i < b.N; i++ {
26                 mining.NewBlockTemplate(chain, txPool, accountManager)
27         }
28 }