aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSuhas Daftuar <sdaftuar@gmail.com>2017-03-08 10:17:58 -0500
committerSuhas Daftuar <sdaftuar@gmail.com>2017-03-30 15:06:14 -0400
commit10028fb5551a210c71e63b065c53cb2a3dddba00 (patch)
treef3ef9f53e56676ad8383fdeb75c70cdcfa19555e /src
parentb5c3440b053217afda5f03ee97b3835f02fd5290 (diff)
downloadbitcoin-10028fb5551a210c71e63b065c53cb2a3dddba00.tar.xz
Add benchmarking for CreateNewBlock
Github-Pull: #9959 Rebased-From: 42cd8c890fb2d65274f26edf95b6d52ac41fcab8
Diffstat (limited to 'src')
-rw-r--r--src/miner.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/miner.cpp b/src/miner.cpp
index 54d66dadd2..89863d3ec2 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -129,6 +129,8 @@ void BlockAssembler::resetBlock()
std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, bool fMineWitnessTx)
{
+ int64_t nTimeStart = GetTimeMicros();
+
resetBlock();
pblocktemplate.reset(new CBlockTemplate());
@@ -170,6 +172,8 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
addPriorityTxs();
addPackageTxs();
+ int64_t nTime1 = GetTimeMicros();
+
nLastBlockTx = nBlockTx;
nLastBlockSize = nBlockSize;
nLastBlockWeight = nBlockWeight;
@@ -200,6 +204,9 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, false, false)) {
throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", __func__, FormatStateMessage(state)));
}
+ int64_t nTime2 = GetTimeMicros();
+
+ LogPrint("bench", "CreateNewBlock() packages: %.2fms, validity: %.2fms (total %.2fms)\n", 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime2 - nTime1), 0.001 * (nTime2 - nTimeStart));
return std::move(pblocktemplate);
}