Bitcoin Core 32.99.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
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:112
bool contains(std::span< const unsigned char > vKey) const
Definition bloom.cpp:235
void insert(std::span< const unsigned char > vKey)
Definition bloom.cpp:204
Main entry point to nanobench's benchmarking facility.
Definition nanobench.h:649
static const PrecomputedData data
Precomputed COutPoint and CCoins values.
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)
static int count
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition time.h:82