scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal instead...
[bitcoinplatinum.git] / src / bench / rollingbloom.cpp
blob73c02cf7189eb1b0514b1bcf8e4cdd61a09e3bd5
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.
5 #include <iostream>
7 #include "bench.h"
8 #include "bloom.h"
9 #include "utiltime.h"
11 static void RollingBloom(benchmark::State& state)
13 CRollingBloomFilter filter(120000, 0.000001);
14 std::vector<unsigned char> data(32);
15 uint32_t count = 0;
16 uint32_t nEntriesPerGeneration = (120000 + 1) / 2;
17 uint32_t countnow = 0;
18 uint64_t match = 0;
19 while (state.KeepRunning()) {
20 count++;
21 data[0] = count;
22 data[1] = count >> 8;
23 data[2] = count >> 16;
24 data[3] = count >> 24;
25 if (countnow == nEntriesPerGeneration) {
26 int64_t b = GetTimeMicros();
27 filter.insert(data);
28 int64_t e = GetTimeMicros();
29 std::cout << "RollingBloom-refresh,1," << (e-b)*0.000001 << "," << (e-b)*0.000001 << "," << (e-b)*0.000001 << "\n";
30 countnow = 0;
31 } else {
32 filter.insert(data);
34 countnow++;
35 data[0] = count >> 24;
36 data[1] = count >> 16;
37 data[2] = count >> 8;
38 data[3] = count;
39 match += filter.contains(data);
43 BENCHMARK(RollingBloom);