Bitcoin Core  29.1.0
P2P Digital Currency
rollingbloom.cpp
Go to the documentation of this file.
1 // Copyright (c) 2016-2022 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 
6 #include <bench/bench.h>
7 #include <common/bloom.h>
8 #include <crypto/common.h>
9 #include <span.h>
10 
11 #include <cstdint>
12 #include <vector>
13 
14 static void RollingBloom(benchmark::Bench& bench)
15 {
16  CRollingBloomFilter filter(120000, 0.000001);
17  std::vector<unsigned char> data(32);
18  uint32_t count = 0;
19  bench.run([&] {
20  count++;
21  WriteLE32(data.data(), count);
22  filter.insert(data);
23 
24  WriteBE32(data.data(), count);
25  filter.contains(data);
26  });
27 }
28 
30 {
31  CRollingBloomFilter filter(120000, 0.000001);
32  bench.run([&] {
33  filter.reset();
34  });
35 }
36 
bool contains(Span< const unsigned char > vKey) const
Definition: bloom.cpp:226
void insert(Span< const unsigned char > vKey)
Definition: bloom.cpp:195
static void RollingBloom(benchmark::Bench &bench)
static void RollingBloomReset(benchmark::Bench &bench)
RollingBloomFilter is a probabilistic "keep track of most recently inserted" set. ...
Definition: bloom.h:108
void WriteLE32(B *ptr, uint32_t x)
Definition: common.h:50
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition: nanobench.h:1234
void WriteBE32(B *ptr, uint32_t x)
Definition: common.h:95
BENCHMARK(RollingBloom, benchmark::PriorityLevel::HIGH)
static int count
Main entry point to nanobench&#39;s benchmarking facility.
Definition: nanobench.h:627