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