Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
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 <bench/bench.h>
6#include <common/bloom.h>
7
9 CRollingBloomFilter filter(120000, 0.000001);
10 std::vector<uint8_t> data(32);
11 uint32_t count = 0;
12 bench.run([&] {
13 count++;
14 data[0] = count & 0xFF;
15 data[1] = (count >> 8) & 0xFF;
16 data[2] = (count >> 16) & 0xFF;
17 data[3] = (count >> 24) & 0xFF;
18 filter.insert(data);
19
20 data[0] = (count >> 24) & 0xFF;
21 data[1] = (count >> 16) & 0xFF;
22 data[2] = (count >> 8) & 0xFF;
23 data[3] = count & 0xFF;
24 filter.contains(data);
25 });
26}
27
29 CRollingBloomFilter filter(120000, 0.000001);
30 bench.run([&] { filter.reset(); });
31}
32
#define BENCHMARK(n)
Definition bench.h:65
RollingBloomFilter is a probabilistic "keep track of most recently inserted" set.
Definition bloom.h:115
void insert(Span< const uint8_t > vKey)
Definition bloom.cpp:215
bool contains(Span< const uint8_t > vKey) const
Definition bloom.cpp:249
Main entry point to nanobench's benchmarking facility.
Definition nanobench.h:616
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
static void RollingBloom(benchmark::Bench &bench)
static void RollingBloomReset(benchmark::Bench &bench)
static int count
Definition tests.c:31