OSDN Git Service

Merge pull request #201 from Bytom/v0.1
[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         dbm "github.com/vapor/database/leveldb"
10         "github.com/vapor/proposal"
11         "github.com/vapor/test"
12 )
13
14 // Function NewBlockTemplate's benchmark - 0.05s
15 func BenchmarkNewBlockTpl(b *testing.B) {
16         testDB := dbm.NewDB("testdb", "leveldb", "temp")
17         defer os.RemoveAll("temp")
18
19         chain, _, txPool, err := test.MockChain(testDB)
20         if err != nil {
21                 b.Fatal(err)
22         }
23         accountManager := account.NewManager(testDB, chain)
24
25         b.ResetTimer()
26         for i := 0; i < b.N; i++ {
27                 proposal.NewBlockTemplate(chain, txPool, accountManager, uint64(time.Now().UnixNano() / 1e6))
28         }
29 }