OSDN Git Service

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