@@ -1492,6 +1492,7 @@ static int64_t nTimeConnect = 0;
1492
1492
static int64_t nTimeIndex = 0 ;
1493
1493
static int64_t nTimeCallbacks = 0 ;
1494
1494
static int64_t nTimeTotal = 0 ;
1495
+ static int64_t nBlocksTotal = 0 ;
1495
1496
1496
1497
/* * Apply the effects of this block (with given index) on the UTXO set represented by coins.
1497
1498
* Validity checks that depend on the UTXO set are also done; ConnectBlock()
@@ -1522,6 +1523,8 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
1522
1523
return true ;
1523
1524
}
1524
1525
1526
+ nBlocksTotal++;
1527
+
1525
1528
bool fScriptChecks = true ;
1526
1529
if (!hashAssumeValid.IsNull ()) {
1527
1530
// We've been configured with the hash of a block which has been externally verified to have a valid history.
@@ -1549,7 +1552,7 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
1549
1552
}
1550
1553
1551
1554
int64_t nTime1 = GetTimeMicros (); nTimeCheck += nTime1 - nTimeStart;
1552
- LogPrint (BCLog::BENCH, " - Sanity checks: %.2fms [%.2fs]\n " , 0.001 * (nTime1 - nTimeStart), nTimeCheck * 0.000001 );
1555
+ LogPrint (BCLog::BENCH, " - Sanity checks: %.2fms [%.2fs (%.2fms/blk) ]\n " , 0.001 * (nTime1 - nTimeStart), nTimeCheck * 0.000001 , nTimeCheck * 0.001 / nBlocksTotal );
1553
1556
1554
1557
// Do not allow blocks that contain transactions which 'overwrite' older transactions,
1555
1558
// unless those are already completely spent.
@@ -1616,7 +1619,7 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
1616
1619
}
1617
1620
1618
1621
int64_t nTime2 = GetTimeMicros (); nTimeForks += nTime2 - nTime1;
1619
- LogPrint (BCLog::BENCH, " - Fork checks: %.2fms [%.2fs]\n " , 0.001 * (nTime2 - nTime1), nTimeForks * 0.000001 );
1622
+ LogPrint (BCLog::BENCH, " - Fork checks: %.2fms [%.2fs (%.2fms/blk) ]\n " , 0.001 * (nTime2 - nTime1), nTimeForks * 0.000001 , nTimeForks * 0.001 / nBlocksTotal );
1620
1623
1621
1624
CBlockUndo blockundo;
1622
1625
@@ -1690,7 +1693,7 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
1690
1693
pos.nTxOffset += ::GetSerializeSize (tx, SER_DISK, CLIENT_VERSION);
1691
1694
}
1692
1695
int64_t nTime3 = GetTimeMicros (); nTimeConnect += nTime3 - nTime2;
1693
- LogPrint (BCLog::BENCH, " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n " , (unsigned )block.vtx .size (), 0.001 * (nTime3 - nTime2), 0.001 * (nTime3 - nTime2) / block.vtx .size (), nInputs <= 1 ? 0 : 0.001 * (nTime3 - nTime2) / (nInputs-1 ), nTimeConnect * 0.000001 );
1696
+ LogPrint (BCLog::BENCH, " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs (%.2fms/blk) ]\n " , (unsigned )block.vtx .size (), 0.001 * (nTime3 - nTime2), 0.001 * (nTime3 - nTime2) / block.vtx .size (), nInputs <= 1 ? 0 : 0.001 * (nTime3 - nTime2) / (nInputs-1 ), nTimeConnect * 0.000001 , nTimeConnect * 0.001 / nBlocksTotal );
1694
1697
1695
1698
CAmount blockReward = nFees + GetBlockSubsidy (pindex->nHeight , chainparams.GetConsensus ());
1696
1699
if (block.vtx [0 ]->GetValueOut () > blockReward)
@@ -1702,7 +1705,7 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
1702
1705
if (!control.Wait ())
1703
1706
return state.DoS (100 , error (" %s: CheckQueue failed" , __func__), REJECT_INVALID, " block-validation-failed" );
1704
1707
int64_t nTime4 = GetTimeMicros (); nTimeVerify += nTime4 - nTime2;
1705
- LogPrint (BCLog::BENCH, " - Verify %u txins: %.2fms (%.3fms/txin) [%.2fs]\n " , nInputs - 1 , 0.001 * (nTime4 - nTime2), nInputs <= 1 ? 0 : 0.001 * (nTime4 - nTime2) / (nInputs-1 ), nTimeVerify * 0.000001 );
1708
+ LogPrint (BCLog::BENCH, " - Verify %u txins: %.2fms (%.3fms/txin) [%.2fs (%.2fms/blk) ]\n " , nInputs - 1 , 0.001 * (nTime4 - nTime2), nInputs <= 1 ? 0 : 0.001 * (nTime4 - nTime2) / (nInputs-1 ), nTimeVerify * 0.000001 , nTimeVerify * 0.001 / nBlocksTotal );
1706
1709
1707
1710
if (fJustCheck )
1708
1711
return true ;
@@ -1734,10 +1737,10 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
1734
1737
view.SetBestBlock (pindex->GetBlockHash ());
1735
1738
1736
1739
int64_t nTime5 = GetTimeMicros (); nTimeIndex += nTime5 - nTime4;
1737
- LogPrint (BCLog::BENCH, " - Index writing: %.2fms [%.2fs]\n " , 0.001 * (nTime5 - nTime4), nTimeIndex * 0.000001 );
1740
+ LogPrint (BCLog::BENCH, " - Index writing: %.2fms [%.2fs (%.2fms/blk) ]\n " , 0.001 * (nTime5 - nTime4), nTimeIndex * 0.000001 , nTimeIndex * 0.001 / nBlocksTotal );
1738
1741
1739
1742
int64_t nTime6 = GetTimeMicros (); nTimeCallbacks += nTime6 - nTime5;
1740
- LogPrint (BCLog::BENCH, " - Callbacks: %.2fms [%.2fs]\n " , 0.001 * (nTime6 - nTime5), nTimeCallbacks * 0.000001 );
1743
+ LogPrint (BCLog::BENCH, " - Callbacks: %.2fms [%.2fs (%.2fms/blk) ]\n " , 0.001 * (nTime6 - nTime5), nTimeCallbacks * 0.000001 , nTimeCallbacks * 0.001 / nBlocksTotal );
1741
1744
1742
1745
return true ;
1743
1746
}
@@ -2088,26 +2091,26 @@ bool static ConnectTip(CValidationState& state, const CChainParams& chainparams,
2088
2091
return error (" ConnectTip(): ConnectBlock %s failed" , pindexNew->GetBlockHash ().ToString ());
2089
2092
}
2090
2093
nTime3 = GetTimeMicros (); nTimeConnectTotal += nTime3 - nTime2;
2091
- LogPrint (BCLog::BENCH, " - Connect total: %.2fms [%.2fs]\n " , (nTime3 - nTime2) * 0.001 , nTimeConnectTotal * 0.000001 );
2094
+ LogPrint (BCLog::BENCH, " - Connect total: %.2fms [%.2fs (%.2fms/blk) ]\n " , (nTime3 - nTime2) * 0.001 , nTimeConnectTotal * 0.000001 , nTimeConnectTotal * 0.001 / nBlocksTotal );
2092
2095
bool flushed = view.Flush ();
2093
2096
assert (flushed);
2094
2097
}
2095
2098
int64_t nTime4 = GetTimeMicros (); nTimeFlush += nTime4 - nTime3;
2096
- LogPrint (BCLog::BENCH, " - Flush: %.2fms [%.2fs]\n " , (nTime4 - nTime3) * 0.001 , nTimeFlush * 0.000001 );
2099
+ LogPrint (BCLog::BENCH, " - Flush: %.2fms [%.2fs (%.2fms/blk) ]\n " , (nTime4 - nTime3) * 0.001 , nTimeFlush * 0.000001 , nTimeFlush * 0.001 / nBlocksTotal );
2097
2100
// Write the chain state to disk, if necessary.
2098
2101
if (!FlushStateToDisk (state, FLUSH_STATE_IF_NEEDED))
2099
2102
return false ;
2100
2103
int64_t nTime5 = GetTimeMicros (); nTimeChainState += nTime5 - nTime4;
2101
- LogPrint (BCLog::BENCH, " - Writing chainstate: %.2fms [%.2fs]\n " , (nTime5 - nTime4) * 0.001 , nTimeChainState * 0.000001 );
2104
+ LogPrint (BCLog::BENCH, " - Writing chainstate: %.2fms [%.2fs (%.2fms/blk) ]\n " , (nTime5 - nTime4) * 0.001 , nTimeChainState * 0.000001 , nTimeChainState * 0.001 / nBlocksTotal );
2102
2105
// Remove conflicting transactions from the mempool.;
2103
2106
mempool.removeForBlock (blockConnecting.vtx , pindexNew->nHeight );
2104
2107
disconnectpool.removeForBlock (blockConnecting.vtx );
2105
2108
// Update chainActive & related variables.
2106
2109
UpdateTip (pindexNew, chainparams);
2107
2110
2108
2111
int64_t nTime6 = GetTimeMicros (); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1;
2109
- LogPrint (BCLog::BENCH, " - Connect postprocess: %.2fms [%.2fs]\n " , (nTime6 - nTime5) * 0.001 , nTimePostConnect * 0.000001 );
2110
- LogPrint (BCLog::BENCH, " - Connect block: %.2fms [%.2fs]\n " , (nTime6 - nTime1) * 0.001 , nTimeTotal * 0.000001 );
2112
+ LogPrint (BCLog::BENCH, " - Connect postprocess: %.2fms [%.2fs (%.2fms/blk) ]\n " , (nTime6 - nTime5) * 0.001 , nTimePostConnect * 0.000001 , nTimePostConnect * 0.001 / nBlocksTotal );
2113
+ LogPrint (BCLog::BENCH, " - Connect block: %.2fms [%.2fs (%.2fms/blk) ]\n " , (nTime6 - nTime1) * 0.001 , nTimeTotal * 0.000001 , nTimeTotal * 0.001 / nBlocksTotal );
2111
2114
2112
2115
connectTrace.BlockConnected (pindexNew, std::move (pthisBlock));
2113
2116
return true ;
0 commit comments