17 std::vector<uint256>
hashes{};
23 constexpr uint256 expected_root{
"d8d4dfd014a533bc3941b8663fa6e7f3a8707af124f713164d75b0c3179ecb08"};
24 for (
bool mutate : {
false,
true}) {
25 bench.name(
mutate ?
"MerkleRootWithMutation" :
"MerkleRoot").batch(
hashes.size()).unit(
"leaf").run([&] {
26 std::vector<uint256> leaves;
27 leaves.reserve((
hashes.size() + 1) & ~1ULL);
28 for (
const auto& hash :
hashes) {
29 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)
static void MerkleRoot(benchmark::Bench &bench)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.