mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
Merge bitcoin/bitcoin#26118: log: Use steady clock for bench logging
fabf1cdb20Use steady clock for bench logging (MacroFake)faed342a23scripted-diff: Rename time symbols (MacroFake) Pull request description: Instead of using `0.001` and similar constants to "convert" an int64_t to milliseconds, use the type-safe `Ticks<>` helper. Also, use steady clock instead of system clock, since the durations are used for benchmarking. ACKs for top commit: fanquake: ACKfabf1cdb20- validation bench output still looks sane. Tree-SHA512: e6525b5fdad6045ca500c56014897d7428ad288aaf375933d3b5939feddf257f6910d562eb66ebcde9186bef9a604ee8d763a318253838318d59df2a285be7c2
This commit is contained in:
@@ -105,7 +105,7 @@ void BlockAssembler::resetBlock()
|
||||
|
||||
std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
{
|
||||
int64_t nTimeStart = GetTimeMicros();
|
||||
const auto time_start{SteadyClock::now()};
|
||||
|
||||
resetBlock();
|
||||
|
||||
@@ -143,7 +143,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
|
||||
addPackageTxs(*m_mempool, nPackagesSelected, nDescendantsUpdated);
|
||||
}
|
||||
|
||||
int64_t nTime1 = GetTimeMicros();
|
||||
const auto time_1{SteadyClock::now()};
|
||||
|
||||
m_last_block_num_txs = nBlockTx;
|
||||
m_last_block_weight = nBlockWeight;
|
||||
@@ -173,9 +173,12 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
|
||||
if (!TestBlockValidity(state, chainparams, m_chainstate, *pblock, pindexPrev, GetAdjustedTime, false, false)) {
|
||||
throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", __func__, state.ToString()));
|
||||
}
|
||||
int64_t nTime2 = GetTimeMicros();
|
||||
const auto time_2{SteadyClock::now()};
|
||||
|
||||
LogPrint(BCLog::BENCH, "CreateNewBlock() packages: %.2fms (%d packages, %d updated descendants), validity: %.2fms (total %.2fms)\n", 0.001 * (nTime1 - nTimeStart), nPackagesSelected, nDescendantsUpdated, 0.001 * (nTime2 - nTime1), 0.001 * (nTime2 - nTimeStart));
|
||||
LogPrint(BCLog::BENCH, "CreateNewBlock() packages: %.2fms (%d packages, %d updated descendants), validity: %.2fms (total %.2fms)\n",
|
||||
Ticks<MillisecondsDouble>(time_1 - time_start), nPackagesSelected, nDescendantsUpdated,
|
||||
Ticks<MillisecondsDouble>(time_2 - time_1),
|
||||
Ticks<MillisecondsDouble>(time_2 - time_start));
|
||||
|
||||
return std::move(pblocktemplate);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user