Skip to content

Commit bd46119

Browse files
committed
bench: support benching all verbosity of BlockToJson
1 parent 5acf12b commit bd46119

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/bench/rpc_blockchain.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,34 @@ struct TestBlockAndIndex {
4545

4646
} // namespace
4747

48-
static void BlockToJsonVerbose(benchmark::Bench& bench)
48+
static void BlockToJson(benchmark::Bench& bench, TxVerbosity verbosity)
4949
{
5050
TestBlockAndIndex data;
5151
const uint256 pow_limit{data.testing_setup->m_node.chainman->GetParams().GetConsensus().powLimit};
5252
bench.run([&] {
53-
auto univalue = blockToJSON(data.testing_setup->m_node.chainman->m_blockman, data.block, data.blockindex, data.blockindex, TxVerbosity::SHOW_DETAILS_AND_PREVOUT, pow_limit);
53+
auto univalue = blockToJSON(data.testing_setup->m_node.chainman->m_blockman, data.block, data.blockindex, data.blockindex, verbosity, pow_limit);
5454
ankerl::nanobench::doNotOptimizeAway(univalue);
5555
});
5656
}
5757

58-
BENCHMARK(BlockToJsonVerbose, benchmark::PriorityLevel::HIGH);
58+
static void BlockToJsonVerbosity1(benchmark::Bench& bench)
59+
{
60+
BlockToJson(bench, TxVerbosity::SHOW_TXID);
61+
}
62+
63+
static void BlockToJsonVerbosity2(benchmark::Bench& bench)
64+
{
65+
BlockToJson(bench, TxVerbosity::SHOW_DETAILS);
66+
}
67+
68+
static void BlockToJsonVerbosity3(benchmark::Bench& bench)
69+
{
70+
BlockToJson(bench, TxVerbosity::SHOW_DETAILS_AND_PREVOUT);
71+
}
72+
73+
BENCHMARK(BlockToJsonVerbosity1, benchmark::PriorityLevel::HIGH);
74+
BENCHMARK(BlockToJsonVerbosity2, benchmark::PriorityLevel::HIGH);
75+
BENCHMARK(BlockToJsonVerbosity3, benchmark::PriorityLevel::HIGH);
5976

6077
static void BlockToJsonVerboseWrite(benchmark::Bench& bench)
6178
{

0 commit comments

Comments
 (0)