MCPcopy Create free account
hub / github.com/CPChain/chain / benchmarkPoolBatchInsert

Function benchmarkPoolBatchInsert

core/tx_pool_test.go:1817–1837  ·  view source on GitHub ↗
(b *testing.B, size int)

Source from the content-addressed store, hash-verified

1815func BenchmarkPoolBatchInsert10000(b *testing.B) { benchmarkPoolBatchInsert(b, 10000) }
1816
1817func benchmarkPoolBatchInsert(b *testing.B, size int) {
1818 // Generate a batch of transactions to enqueue into the pool
1819 pool, key := setupTxPool()
1820 defer pool.Stop()
1821
1822 account, _ := deriveSender(transaction(0, 0, key))
1823 pool.currentState.AddBalance(account, big.NewInt(1000000))
1824
1825 batches := make([]types.Transactions, b.N)
1826 for i := 0; i < b.N; i++ {
1827 batches[i] = make(types.Transactions, size)
1828 for j := 0; j < size; j++ {
1829 batches[i][j] = transaction(uint64(size*i+j), 100000, key)
1830 }
1831 }
1832 // Benchmark importing the transactions into the queue
1833 b.ResetTimer()
1834 for _, batch := range batches {
1835 pool.AddRemotes(batch)
1836 }
1837}

Callers 3

Calls 6

setupTxPoolFunction · 0.85
deriveSenderFunction · 0.85
transactionFunction · 0.85
StopMethod · 0.65
AddBalanceMethod · 0.65
AddRemotesMethod · 0.65

Tested by

no test coverage detected