Bitcoin Core 28.99.0
P2P Digital Currency
rollingbloom.cpp
Go to the documentation of this file.
1// Copyright (c) 2016-2022 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 <common/bloom.h>
8#include <crypto/common.h>
9#include <span.h>
10
11#include <cstdint>
12#include <vector>
13
14static void RollingBloom(benchmark::Bench& bench)
15{
16 CRollingBloomFilter filter(120000, 0.000001);
17 std::vector<unsigned char> data(32);
18 uint32_t count = 0;
19 bench.run([&] {
20 count++;
21 WriteLE32(data.data(), count);
22 filter.insert(data);
23
24 WriteBE32(data.data(), count);
25 filter.contains(data);
26 });
27}
28
30{
31 CRollingBloomFilter filter(120000, 0.000001);
32 bench.run([&] {
33 filter.reset();
34 });
35}
36
RollingBloomFilter is a probabilistic "keep track of most recently inserted" set.
Definition: bloom.h:109
bool contains(Span< const unsigned char > vKey) const
Definition: bloom.cpp:226
void insert(Span< const unsigned char > vKey)
Definition: bloom.cpp:195
Main entry point to nanobench's benchmarking facility.
Definition: nanobench.h:627
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition: nanobench.h:1234
static void WriteBE32(unsigned char *ptr, uint32_t x)
Definition: common.h:79
static void WriteLE32(unsigned char *ptr, uint32_t x)
Definition: common.h:40
@ HIGH
Definition: bench.h:48
static void RollingBloom(benchmark::Bench &bench)
BENCHMARK(RollingBloom, benchmark::PriorityLevel::HIGH)
static void RollingBloomReset(benchmark::Bench &bench)
static int count