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.

31 lines
597 B

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