aboutsummaryrefslogtreecommitdiff
path: root/src/miner.cpp
diff options
context:
space:
mode:
authorSuhas Daftuar <sdaftuar@gmail.com>2017-03-08 10:17:58 -0500
committerSuhas Daftuar <sdaftuar@gmail.com>2017-03-29 13:57:52 -0400
commit42cd8c890fb2d65274f26edf95b6d52ac41fcab8 (patch)
tree5a1f292600e67c91993bf54003f4b91b3d716f44 /src/miner.cpp
parenteed816af6c68c0c67f5fc05472a3927db62f8a18 (diff)
Add benchmarking for CreateNewBlock
Diffstat (limited to 'src/miner.cpp')
-rw-r--r--src/miner.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/miner.cpp b/src/miner.cpp
index 570053a53b..ffde2ed803 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -139,6 +139,8 @@ void BlockAssembler::resetBlock()
std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn)
{
+ int64_t nTimeStart = GetTimeMicros();
+
resetBlock();
pblocktemplate.reset(new CBlockTemplate());
@@ -179,6 +181,8 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
addPackageTxs();
+ int64_t nTime1 = GetTimeMicros();
+
nLastBlockTx = nBlockTx;
nLastBlockSize = nBlockSize;
nLastBlockWeight = nBlockWeight;
@@ -209,6 +213,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);
}