| 9 | #include <uint256.h> |
| 10 | |
| 11 | static void MerkleRoot(benchmark::Bench& bench) |
| 12 | { |
| 13 | FastRandomContext rng(true); |
| 14 | std::vector<uint256> leaves; |
| 15 | leaves.resize(9001); |
| 16 | for (auto& item : leaves) { |
| 17 | item = rng.rand256(); |
| 18 | } |
| 19 | bench.batch(leaves.size()).unit("leaf").run([&] { |
| 20 | bool mutation = false; |
| 21 | uint256 hash = ComputeMerkleRoot(std::vector<uint256>(leaves), &mutation); |
| 22 | leaves[mutation] = hash; |
| 23 | }); |
| 24 | } |
| 25 | |
| 26 | BENCHMARK(MerkleRoot); |