mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-24 11:57:44 +08:00
Note: This commit is technically broken. However, I need to make a bunch of cmds changes to make this work and I'd rather not bundle both changes into a single commit. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
31 lines
857 B
Go
31 lines
857 B
Go
package decision
|
|
|
|
import (
|
|
"fmt"
|
|
"math"
|
|
"testing"
|
|
|
|
"github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
|
|
cid "gx/ipfs/QmNp85zy9RLrQ5oQD4hPyS39ezrrXpcaa7R4Y9kxdWQLLQ/go-cid"
|
|
"gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil"
|
|
u "gx/ipfs/QmSU6eubNdhXjFBJBSksTp8kv8YRub8mGAPv8tVJHmL2EU/go-ipfs-util"
|
|
"gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer"
|
|
)
|
|
|
|
// 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 := newPRQ()
|
|
peers := []peer.ID{
|
|
testutil.RandPeerIDFatal(b),
|
|
testutil.RandPeerIDFatal(b),
|
|
testutil.RandPeerIDFatal(b),
|
|
}
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
c := cid.NewCidV0(u.Hash([]byte(fmt.Sprint(i))))
|
|
|
|
q.Push(&wantlist.Entry{Cid: c, Priority: math.MaxInt32}, peers[i%len(peers)])
|
|
}
|
|
}
|