2018-07-27 00:36:45 +02:00
|
|
|
// Copyright (c) 2016-2018 The Bitcoin Core developers
|
2017-09-28 02:36:56 +02:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2018-05-14 09:51:03 +02:00
|
|
|
#include <bench/bench.h>
|
2017-09-28 02:36:56 +02:00
|
|
|
|
2018-05-14 09:51:03 +02:00
|
|
|
#include <uint256.h>
|
|
|
|
#include <random.h>
|
|
|
|
#include <consensus/merkle.h>
|
2017-09-28 02:36:56 +02:00
|
|
|
|
|
|
|
static void MerkleRoot(benchmark::State& state)
|
|
|
|
{
|
|
|
|
FastRandomContext rng(true);
|
|
|
|
std::vector<uint256> leaves;
|
|
|
|
leaves.resize(9001);
|
|
|
|
for (auto& item : leaves) {
|
|
|
|
item = rng.rand256();
|
|
|
|
}
|
|
|
|
while (state.KeepRunning()) {
|
|
|
|
bool mutation = false;
|
2017-09-28 03:50:31 +02:00
|
|
|
uint256 hash = ComputeMerkleRoot(std::vector<uint256>(leaves), &mutation);
|
2017-09-28 02:36:56 +02:00
|
|
|
leaves[mutation] = hash;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BENCHMARK(MerkleRoot, 800);
|