18 std::vector<uint256>
hashes{};
24 constexpr uint256 expected_root{
"d8d4dfd014a533bc3941b8663fa6e7f3a8707af124f713164d75b0c3179ecb08"};
25 for (
bool mutate : {
false,
true}) {
26 bench.name(
mutate ?
"MerkleRootWithMutation" :
"MerkleRoot").batch(
hashes.size()).unit(
"leaf").run([&] {
27 std::vector<uint256> leaves;
28 leaves.reserve((
hashes.size() + 1) & ~1ULL);
29 for (
const auto& hash :
hashes) {
30 leaves.push_back(hash);
uint256 rand256() noexcept
generate a random uint256.
Main entry point to nanobench's benchmarking facility.
uint256 ComputeMerkleRoot(std::vector< uint256 > hashes, bool *mutated)
Compute a Merkle root from the provided leaf hashes.
static void MerkleRoot(benchmark::Bench &bench)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.