Bitcoin ABC
0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
src
bench
lockedpool.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
7
#include <
support/lockedpool.h
>
8
9
#include <vector>
10
11
#define ASIZE 2048
12
#define MSIZE 2048
13
14
static
void
BenchLockedPool
(
benchmark::Bench
&
bench
) {
15
void
*
synth_base
=
reinterpret_cast<
void
*
>
(0x08000000);
16
const
size_t
synth_size
= 1024 * 1024;
17
Arena
b
(
synth_base
,
synth_size
, 16);
18
19
std::vector<void *> addr;
20
for
(
int
x = 0; x <
ASIZE
; ++x) {
21
addr.push_back(
nullptr
);
22
}
23
uint32_t
s = 0x12345678;
24
bench
.run([&] {
25
int
idx = s & (addr.size() - 1);
26
if
(s & 0x80000000) {
27
b
.free(addr[idx]);
28
addr[idx] =
nullptr
;
29
}
else
if
(!addr[idx]) {
30
addr[idx] =
b
.alloc((s >> 16) & (
MSIZE
- 1));
31
}
32
bool
lsb
= s & 1;
33
s >>= 1;
34
if
(
lsb
) {
35
// LFSR period 0xf7ffffe0
36
s ^= 0xf00f00f0;
37
}
38
});
39
for
(
void
*ptr : addr) {
40
b
.free(ptr);
41
}
42
addr.clear();
43
}
44
45
BENCHMARK
(
BenchLockedPool
);
bench.h
BENCHMARK
#define BENCHMARK(n)
Definition
bench.h:65
ASIZE
#define ASIZE
Definition
lockedpool.cpp:11
MSIZE
#define MSIZE
Definition
lockedpool.cpp:12
BenchLockedPool
static void BenchLockedPool(benchmark::Bench &bench)
Definition
lockedpool.cpp:14
Arena
An arena manages a contiguous region of memory by dividing it into chunks.
Definition
lockedpool.h:50
ankerl::nanobench::Bench
Main entry point to nanobench's benchmarking facility.
Definition
nanobench.h:616
lockedpool.h
GetRand
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
Generated on Fri Dec 27 2024 02:38:14 for Bitcoin ABC by
1.9.8