Add performance test for adding txs in random order

This commit is contained in:
Mark Spanbroek 2021-09-06 16:07:45 +02:00
parent ec1a013678
commit 0745114856
1 changed files with 9 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import std/times import std/times
import std/strutils import std/strutils
import std/random
import abc/txstore import abc/txstore
import ./basics import ./basics
import ./alicebob import ./alicebob
@ -68,6 +69,14 @@ suite "Performance":
inc index inc index
statistic "transactions per second", count * 100 statistic "transactions per second", count * 100
test "↑↑↑ add transactions in random order ↑↑↑":
let transactions = generateTransactions(10_000)
var store = TxStore.new(Transaction.genesis)
for _ in 0..<4:
let count = repeat(initDuration(milliseconds = 10)):
store.add(transactions.sample)
statistic "transactions per second", count * 100
proc generateAcks(transactions: openArray[Transaction]): seq[Ack] = proc generateAcks(transactions: openArray[Transaction]): seq[Ack] =
var ack: ?Ack var ack: ?Ack
for tx in transactions: for tx in transactions: