You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
653 B

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