1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-10 05:52:20 +08:00

tests: add bench

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
This commit is contained in:
Brian Tiger Chow
2014-12-18 23:34:48 -05:00
parent cb1ef6e1e2
commit 0239379303

View File

@ -0,0 +1,25 @@
package decision
import (
"math"
"testing"
"github.com/jbenet/go-ipfs/exchange/bitswap/wantlist"
"github.com/jbenet/go-ipfs/p2p/peer"
"github.com/jbenet/go-ipfs/util"
"github.com/jbenet/go-ipfs/util/testutil"
)
// FWIW: At the time of this commit, including a timestamp in task increases
// time cost of Push by 3%.
func BenchmarkTaskQueuePush(b *testing.B) {
q := newTaskQueue()
peers := []peer.ID{
testutil.RandPeerIDFatal(b),
testutil.RandPeerIDFatal(b),
testutil.RandPeerIDFatal(b),
}
for i := 0; i < b.N; i++ {
q.Push(wantlist.Entry{Key: util.Key(i), Priority: math.MaxInt32}, peers[i%len(peers)])
}
}