github.com/keltia/go-ipfs@v0.3.8-0.20150909044612-210793031c63/exchange/bitswap/decision/bench_test.go (about) 1 package decision 2 3 import ( 4 "math" 5 "testing" 6 7 key "github.com/ipfs/go-ipfs/blocks/key" 8 "github.com/ipfs/go-ipfs/exchange/bitswap/wantlist" 9 "github.com/ipfs/go-ipfs/p2p/peer" 10 "github.com/ipfs/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 := newPRQ() 17 peers := []peer.ID{ 18 testutil.RandPeerIDFatal(b), 19 testutil.RandPeerIDFatal(b), 20 testutil.RandPeerIDFatal(b), 21 } 22 b.ResetTimer() 23 for i := 0; i < b.N; i++ { 24 q.Push(wantlist.Entry{Key: key.Key(i), Priority: math.MaxInt32}, peers[i%len(peers)]) 25 } 26 }