@cryptotaxi247 / kubo / commits / 023937930

tests: add bench

License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>

Brian Tiger Chow committed Dec 18, 2014 at 23:34 UTC 0239379303f513937baf9fac9dc7a6147e8efe2a
1 file changed +25
exchange/bitswap/decision/bench_test.go new
+25
@@ -0,0 +1,25 @@
1 +package decision
2 +
3 +import (
4 + "math"
5 + "testing"
6 +
7 + "github.com/jbenet/go-ipfs/exchange/bitswap/wantlist"
8 + "github.com/jbenet/go-ipfs/p2p/peer"
9 + "github.com/jbenet/go-ipfs/util"
10 + "github.com/jbenet/go-ipfs/util/testutil"
11 +)
12 +
13 +// FWIW: At the time of this commit, including a timestamp in task increases
14 +// time cost of Push by 3%.
15 +func BenchmarkTaskQueuePush(b *testing.B) {
16 + q := newTaskQueue()
17 + peers := []peer.ID{
18 + testutil.RandPeerIDFatal(b),
19 + testutil.RandPeerIDFatal(b),
20 + testutil.RandPeerIDFatal(b),
21 + }
22 + for i := 0; i < b.N; i++ {
23 + q.Push(wantlist.Entry{Key: util.Key(i), Priority: math.MaxInt32}, peers[i%len(peers)])
24 + }
25 +}