forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(Partial)Merge bitcoin#15473: bench: Benchmark MempoolToJSON
- Loading branch information
1 parent
3eb87e7
commit ed87626
Showing
7 changed files
with
72 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) 2011-2019 The Bitcoin Core developers | ||
// Copyright (c) 2014-2021 The Dash Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#include <bench/bench.h> | ||
#include <policy/policy.h> | ||
#include <rpc/blockchain.h> | ||
#include <txmempool.h> | ||
|
||
#include <univalue.h> | ||
|
||
#include <list> | ||
#include <vector> | ||
|
||
static void AddTx(const CTransactionRef& tx, const CAmount& fee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs) | ||
{ | ||
LockPoints lp; | ||
pool.addUnchecked(CTxMemPoolEntry(tx, fee, /* time */ 0, /* height */ 1, /* spendsCoinbase */ false, /* sigOpCost */ 4, lp)); | ||
} | ||
|
||
static void RpcMempool(benchmark::State& state) | ||
{ | ||
CTxMemPool pool; | ||
LOCK2(cs_main, pool.cs); | ||
|
||
for (int i = 0; i < 1000; ++i) { | ||
CMutableTransaction tx = CMutableTransaction(); | ||
tx.vin.resize(1); | ||
tx.vin[0].scriptSig = CScript() << OP_1; | ||
tx.vin[0].scriptWitness.stack.push_back({1}); | ||
tx.vout.resize(1); | ||
tx.vout[0].scriptPubKey = CScript() << OP_1 << OP_EQUAL; | ||
tx.vout[0].nValue = i; | ||
const CTransactionRef tx_r{MakeTransactionRef(tx)}; | ||
AddTx(tx_r, /* fee */ i, pool); | ||
} | ||
|
||
while (state.KeepRunning()) { | ||
(void)MempoolToJSON(pool, /*verbose*/ true); | ||
} | ||
} | ||
|
||
BENCHMARK(RpcMempool); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters