Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

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 <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  uint32_t nEntriesPerGeneration = (120000 + 1) / 2;
16  uint32_t countnow = 0;
17  uint64_t match = 0;
18  while (state.KeepRunning()) {
19  count++;
20  data[0] = count;
21  data[1] = count >> 8;
22  data[2] = count >> 16;
23  data[3] = count >> 24;
24  if (countnow == nEntriesPerGeneration) {
25  auto b = benchmark::clock::now();
26  filter.insert(data);
27  auto total = std::chrono::duration_cast<std::chrono::nanoseconds>(benchmark::clock::now() - b).count();
28  std::cout << "RollingBloom-refresh,1," << total << "," << total << "," << total << "\n";
29  countnow = 0;
30  } else {
31  filter.insert(data);
32  }
33  countnow++;
34  data[0] = count >> 24;
35  data[1] = count >> 16;
36  data[2] = count >> 8;
37  data[3] = count;
38  match += filter.contains(data);
39  }
40 }
41 
void insert(const std::vector< unsigned char > &vKey)
Definition: bloom.cpp:341
bool KeepRunning()
Definition: bench.cpp:39
RollingBloomFilter is a probabilistic "keep track of most recently inserted" set. ...
Definition: bloom.h:126
static void RollingBloom(benchmark::State &state)
bool contains(const std::vector< unsigned char > &vKey) const
Definition: bloom.cpp:378
static int count
Definition: tests.c:45
BENCHMARK(RollingBloom)
Released under the MIT license