Bitcoin ABC  0.24.10
P2P Digital Currency
rollingbloom.cpp
Go to the documentation of this file.
1 // Copyright (c) 2016 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <bench/bench.h>
6 #include <bloom.h>
7 
8 static void RollingBloom(benchmark::Bench &bench) {
9  CRollingBloomFilter filter(120000, 0.000001);
10  std::vector<uint8_t> data(32);
11  uint32_t count = 0;
12  bench.run([&] {
13  count++;
14  data[0] = count;
15  data[1] = count >> 8;
16  data[2] = count >> 16;
17  data[3] = count >> 24;
18  filter.insert(data);
19 
20  data[0] = count >> 24;
21  data[1] = count >> 16;
22  data[2] = count >> 8;
23  data[3] = count;
24  filter.contains(data);
25  });
26 }
27 
28 static void RollingBloomReset(benchmark::Bench &bench) {
29  CRollingBloomFilter filter(120000, 0.000001);
30  bench.run([&] { filter.reset(); });
31 }
32 
count
static int count
Definition: tests.c:41
ankerl::nanobench::Bench
Main entry point to nanobench's benchmarking facility.
Definition: nanobench.h:583
bloom.h
ankerl::nanobench::Bench::run
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition: nanobench.h:1134
CRollingBloomFilter::reset
void reset()
Definition: bloom.cpp:294
bench.h
CRollingBloomFilter::insert
void insert(const std::vector< uint8_t > &vKey)
Definition: bloom.cpp:236
RollingBloomReset
static void RollingBloomReset(benchmark::Bench &bench)
Definition: rollingbloom.cpp:28
RollingBloom
static void RollingBloom(benchmark::Bench &bench)
Definition: rollingbloom.cpp:8
CRollingBloomFilter
RollingBloomFilter is a probabilistic "keep track of most recently inserted" set.
Definition: bloom.h:119
CRollingBloomFilter::contains
bool contains(const std::vector< uint8_t > &vKey) const
Definition: bloom.cpp:275
BENCHMARK
BENCHMARK(RollingBloom)