Files
bitcoin/src/bench/lockedpool.cpp
MarcoFalke fa51a28a94 scripted-diff: Remove priority_level from BENCHMARK macro
-BEGIN VERIFY SCRIPT-

 sed --in-place --regexp-extended 's/BENCHMARK\(([^,]+), benchmark::PriorityLevel::(HIGH|LOW)\)/BENCHMARK(\1)/g' $( git grep -l PriorityLevel )
 sed --in-place                   's/#define BENCHMARK(n, priority_level)/#define BENCHMARK(n)/g'                ./src/bench/bench.h

-END VERIFY SCRIPT-
2026-01-13 08:33:37 +01:00

42 lines
1.1 KiB
C++

// Copyright (c) 2016-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
#include <support/lockedpool.h>
#include <cstddef>
#include <cstdint>
#include <vector>
#define ASIZE 2048
#define MSIZE 2048
static void BenchLockedPool(benchmark::Bench& bench)
{
void *synth_base = reinterpret_cast<void*>(0x08000000);
const size_t synth_size = 1024*1024;
Arena b(synth_base, synth_size, 16);
std::vector<void*> addr{ASIZE, nullptr};
uint32_t s = 0x12345678;
bench.run([&] {
int idx = s & (addr.size() - 1);
if (s & 0x80000000) {
b.free(addr[idx]);
addr[idx] = nullptr;
} else if (!addr[idx]) {
addr[idx] = b.alloc((s >> 16) & (MSIZE - 1));
}
bool lsb = s & 1;
s >>= 1;
if (lsb)
s ^= 0xf00f00f0; // LFSR period 0xf7ffffe0
});
for (void *ptr: addr)
b.free(ptr);
addr.clear();
}
BENCHMARK(BenchLockedPool);