bench: support benching all verbosity of BlockToJson

This commit is contained in:
ismaelsadeeq
2024-12-23 17:13:39 -05:00
parent 5acf12bafe
commit bd461195f4

View File

@@ -45,17 +45,34 @@ struct TestBlockAndIndex {
} // namespace
static void BlockToJsonVerbose(benchmark::Bench& bench)
static void BlockToJson(benchmark::Bench& bench, TxVerbosity verbosity)
{
TestBlockAndIndex data;
const uint256 pow_limit{data.testing_setup->m_node.chainman->GetParams().GetConsensus().powLimit};
bench.run([&] {
auto univalue = blockToJSON(data.testing_setup->m_node.chainman->m_blockman, data.block, data.blockindex, data.blockindex, TxVerbosity::SHOW_DETAILS_AND_PREVOUT, pow_limit);
auto univalue = blockToJSON(data.testing_setup->m_node.chainman->m_blockman, data.block, data.blockindex, data.blockindex, verbosity, pow_limit);
ankerl::nanobench::doNotOptimizeAway(univalue);
});
}
BENCHMARK(BlockToJsonVerbose, benchmark::PriorityLevel::HIGH);
static void BlockToJsonVerbosity1(benchmark::Bench& bench)
{
BlockToJson(bench, TxVerbosity::SHOW_TXID);
}
static void BlockToJsonVerbosity2(benchmark::Bench& bench)
{
BlockToJson(bench, TxVerbosity::SHOW_DETAILS);
}
static void BlockToJsonVerbosity3(benchmark::Bench& bench)
{
BlockToJson(bench, TxVerbosity::SHOW_DETAILS_AND_PREVOUT);
}
BENCHMARK(BlockToJsonVerbosity1, benchmark::PriorityLevel::HIGH);
BENCHMARK(BlockToJsonVerbosity2, benchmark::PriorityLevel::HIGH);
BENCHMARK(BlockToJsonVerbosity3, benchmark::PriorityLevel::HIGH);
static void BlockToJsonVerboseWrite(benchmark::Bench& bench)
{