From 0df017889b4f61860092e1d54e271092cce55f62 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Wed, 27 Sep 2017 17:36:56 -0700 Subject: Benchmark Merkle root computation --- src/bench/merkle_root.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/bench/merkle_root.cpp (limited to 'src/bench') diff --git a/src/bench/merkle_root.cpp b/src/bench/merkle_root.cpp new file mode 100644 index 0000000000..027b19125d --- /dev/null +++ b/src/bench/merkle_root.cpp @@ -0,0 +1,26 @@ +// Copyright (c) 2016 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "bench.h" + +#include "uint256.h" +#include "random.h" +#include "consensus/merkle.h" + +static void MerkleRoot(benchmark::State& state) +{ + FastRandomContext rng(true); + std::vector leaves; + leaves.resize(9001); + for (auto& item : leaves) { + item = rng.rand256(); + } + while (state.KeepRunning()) { + bool mutation = false; + uint256 hash = ComputeMerkleRoot(leaves, &mutation); + leaves[mutation] = hash; + } +} + +BENCHMARK(MerkleRoot, 800); -- cgit v1.2.3 From d0c96328833127284574bfef26f96aa2e4afc91a Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Tue, 26 Sep 2017 18:29:42 -0700 Subject: Specialized double sha256 for 64 byte inputs --- src/bench/crypto_hash.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/bench') diff --git a/src/bench/crypto_hash.cpp b/src/bench/crypto_hash.cpp index adb69bc6c3..7d907eaf10 100644 --- a/src/bench/crypto_hash.cpp +++ b/src/bench/crypto_hash.cpp @@ -52,6 +52,14 @@ static void SHA256_32b(benchmark::State& state) } } +static void SHA256D64_1024(benchmark::State& state) +{ + std::vector in(64 * 1024, 0); + while (state.KeepRunning()) { + SHA256D64(in.data(), in.data(), 1024); + } +} + static void SHA512(benchmark::State& state) { uint8_t hash[CSHA512::OUTPUT_SIZE]; @@ -94,5 +102,6 @@ BENCHMARK(SHA512, 330); BENCHMARK(SHA256_32b, 4700 * 1000); BENCHMARK(SipHash_32b, 40 * 1000 * 1000); +BENCHMARK(SHA256D64_1024, 7400); BENCHMARK(FastRandom_32bit, 110 * 1000 * 1000); BENCHMARK(FastRandom_1bit, 440 * 1000 * 1000); -- cgit v1.2.3 From 1f0e7ca09c9d7c5787c218156fa5096a1bdf2ea8 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Wed, 27 Sep 2017 18:50:31 -0700 Subject: Use SHA256D64 in Merkle root computation --- src/bench/merkle_root.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/bench') diff --git a/src/bench/merkle_root.cpp b/src/bench/merkle_root.cpp index 027b19125d..ae2a0a28dc 100644 --- a/src/bench/merkle_root.cpp +++ b/src/bench/merkle_root.cpp @@ -18,7 +18,7 @@ static void MerkleRoot(benchmark::State& state) } while (state.KeepRunning()) { bool mutation = false; - uint256 hash = ComputeMerkleRoot(leaves, &mutation); + uint256 hash = ComputeMerkleRoot(std::vector(leaves), &mutation); leaves[mutation] = hash; } } -- cgit v1.2.3