diff options
author | Jim Posen <jim.posen@gmail.com> | 2018-05-13 22:27:14 -0700 |
---|---|---|
committer | Jim Posen <jim.posen@gmail.com> | 2018-08-25 10:02:37 -0700 |
commit | 254c85b68794ada713dbdae415db72adf5fcbaf3 (patch) | |
tree | 7f733a1ca7c214ffe01e25e4021f7fdc4b2790cc /src | |
parent | f33b717a85363e067316c133a542559d2f4aaeca (diff) |
bench: Benchmark GCS filter creation and matching.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.bench.include | 1 | ||||
-rw-r--r-- | src/bench/gcs_filter.cpp | 43 |
2 files changed, 44 insertions, 0 deletions
diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include index f5293585a0..76177630ab 100644 --- a/src/Makefile.bench.include +++ b/src/Makefile.bench.include @@ -22,6 +22,7 @@ bench_bench_bitcoin_SOURCES = \ bench/rollingbloom.cpp \ bench/crypto_hash.cpp \ bench/ccoins_caching.cpp \ + bench/gcs_filter.cpp \ bench/merkle_root.cpp \ bench/mempool_eviction.cpp \ bench/verify_script.cpp \ diff --git a/src/bench/gcs_filter.cpp b/src/bench/gcs_filter.cpp new file mode 100644 index 0000000000..6f4e384e3b --- /dev/null +++ b/src/bench/gcs_filter.cpp @@ -0,0 +1,43 @@ +// Copyright (c) 2018 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/bench.h> +#include <blockfilter.h> + +static void ConstructGCSFilter(benchmark::State& state) +{ + GCSFilter::ElementSet elements; + for (int i = 0; i < 10000; ++i) { + GCSFilter::Element element(32); + element[0] = static_cast<unsigned char>(i); + element[1] = static_cast<unsigned char>(i >> 8); + elements.insert(std::move(element)); + } + + uint64_t siphash_k0 = 0; + while (state.KeepRunning()) { + GCSFilter filter(siphash_k0, 0, 20, 1 << 20, elements); + + siphash_k0++; + } +} + +static void MatchGCSFilter(benchmark::State& state) +{ + GCSFilter::ElementSet elements; + for (int i = 0; i < 10000; ++i) { + GCSFilter::Element element(32); + element[0] = static_cast<unsigned char>(i); + element[1] = static_cast<unsigned char>(i >> 8); + elements.insert(std::move(element)); + } + GCSFilter filter(0, 0, 20, 1 << 20, elements); + + while (state.KeepRunning()) { + filter.Match(GCSFilter::Element()); + } +} + +BENCHMARK(ConstructGCSFilter, 1000); +BENCHMARK(MatchGCSFilter, 50 * 1000); |