Fabcoin Core  0.16.2
P2P Digital Currency
rollingbloom.cpp
Go to the documentation of this file.
1 // Copyright (c) 2016-2017 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 <iostream>
6 
7 #include <bench/bench.h>
8 #include <bloom.h>
9 
10 static void RollingBloom(benchmark::State& state)
11 {
12  CRollingBloomFilter filter(120000, 0.000001);
13  std::vector<unsigned char> data(32);
14  uint32_t count = 0;
15  uint64_t match = 0;
16  while (state.KeepRunning()) {
17  count++;
18  data[0] = count;
19  data[1] = count >> 8;
20  data[2] = count >> 16;
21  data[3] = count >> 24;
22  filter.insert(data);
23 
24  data[0] = count >> 24;
25  data[1] = count >> 16;
26  data[2] = count >> 8;
27  data[3] = count;
28  match += filter.contains(data);
29  }
30 }
31 
32 BENCHMARK(RollingBloom, 1500 * 1000);
BENCHMARK(RollingBloom, 1500 *1000)
size_t count
Definition: ExecStats.cpp:37
bool KeepRunning()
Definition: bench.h:70
RollingBloomFilter is a probabilistic "keep track of most recently inserted" set. ...
Definition: bloom.h:119
uint8_t const * data
Definition: sha3.h:19