|
|
@ -2,6 +2,7 @@ package mempool |
|
|
|
|
|
|
|
import ( |
|
|
|
"encoding/binary" |
|
|
|
"sync/atomic" |
|
|
|
"testing" |
|
|
|
|
|
|
|
"github.com/tendermint/tendermint/abci/example/kvstore" |
|
|
@ -54,25 +55,21 @@ func BenchmarkParallelCheckTx(b *testing.B) { |
|
|
|
|
|
|
|
mempool.config.Size = 100000000 |
|
|
|
|
|
|
|
txCt := 500000000 |
|
|
|
counter := make(chan int, txCt) |
|
|
|
for i := 0; i < txCt; i++ { |
|
|
|
counter <- i |
|
|
|
var txcnt uint64 |
|
|
|
next := func() uint64 { |
|
|
|
return atomic.AddUint64(&txcnt, 1) - 1 |
|
|
|
} |
|
|
|
close(counter) |
|
|
|
|
|
|
|
b.ResetTimer() |
|
|
|
for i := 0; i < b.N; i++ { |
|
|
|
b.RunParallel(func(pb *testing.PB) { |
|
|
|
for pb.Next() { |
|
|
|
tx := make([]byte, 8) |
|
|
|
binary.BigEndian.PutUint64(tx, uint64(<-counter)) |
|
|
|
if err := mempool.CheckTx(tx, nil, TxInfo{}); err != nil { |
|
|
|
b.Fatal(err) |
|
|
|
} |
|
|
|
b.RunParallel(func(pb *testing.PB) { |
|
|
|
for pb.Next() { |
|
|
|
tx := make([]byte, 8) |
|
|
|
binary.BigEndian.PutUint64(tx, next()) |
|
|
|
if err := mempool.CheckTx(tx, nil, TxInfo{}); err != nil { |
|
|
|
b.Fatal(err) |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
func BenchmarkCheckDuplicateTx(b *testing.B) { |
|
|
|