Bitcoin Core  0.19.99
P2P Digital Currency
rollingbloom.cpp
Go to the documentation of this file.
1 // Copyright (c) 2016-2019 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 <bloom.h>
8 
9 static void RollingBloom(benchmark::State& state)
10 {
11  CRollingBloomFilter filter(120000, 0.000001);
12  std::vector<unsigned char> data(32);
13  uint32_t count = 0;
14  while (state.KeepRunning()) {
15  count++;
16  data[0] = count;
17  data[1] = count >> 8;
18  data[2] = count >> 16;
19  data[3] = count >> 24;
20  filter.insert(data);
21 
22  data[0] = count >> 24;
23  data[1] = count >> 16;
24  data[2] = count >> 8;
25  data[3] = count;
26  filter.contains(data);
27  }
28 }
29 
31 {
32  CRollingBloomFilter filter(120000, 0.000001);
33  while (state.KeepRunning()) {
34  filter.reset();
35  }
36 }
37 
38 BENCHMARK(RollingBloom, 1500 * 1000);
BENCHMARK(RollingBloom, 1500 *1000)
void insert(const std::vector< unsigned char > &vKey)
Definition: bloom.cpp:246
bool KeepRunning()
Definition: bench.h:72
RollingBloomFilter is a probabilistic "keep track of most recently inserted" set. ...
Definition: bloom.h:115
static void RollingBloom(benchmark::State &state)
Definition: rollingbloom.cpp:9
bool contains(const std::vector< unsigned char > &vKey) const
Definition: bloom.cpp:283
static int count
Definition: tests.c:45
static void RollingBloomReset(benchmark::State &state)