github.com/Finschia/ostracon@v1.1.5/mempool/v1/mempool_bench_test.go (about) 1 //go:build deprecated 2 3 package v1 4 5 import ( 6 "fmt" 7 "math/rand" 8 "testing" 9 "time" 10 11 "github.com/stretchr/testify/require" 12 13 "github.com/tendermint/tendermint/mempool" 14 ) 15 16 func BenchmarkTxMempool_CheckTx(b *testing.B) { 17 txmp := setup(b, 10000) 18 rng := rand.New(rand.NewSource(time.Now().UnixNano())) 19 20 b.ResetTimer() 21 22 for n := 0; n < b.N; n++ { 23 b.StopTimer() 24 prefix := make([]byte, 20) 25 _, err := rng.Read(prefix) 26 require.NoError(b, err) 27 28 priority := int64(rng.Intn(9999-1000) + 1000) 29 tx := []byte(fmt.Sprintf("%X=%d", prefix, priority)) 30 b.StartTimer() 31 32 require.NoError(b, txmp.CheckTx(tx, nil, mempool.TxInfo{})) 33 } 34 }