From e204c5c6239bc9fe431cfa42a37c3c039f76e5e4 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 18 Oct 2016 17:49:02 +0200 Subject: [PATCH] bench: Add benchmark for lockedpool allocation/deallocation --- src/Makefile.bench.include | 1 + src/bench/lockedpool.cpp | 47 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/bench/lockedpool.cpp diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include index 5a8356aa5..6f1b9df99 100644 --- a/src/Makefile.bench.include +++ b/src/Makefile.bench.include @@ -13,6 +13,7 @@ bench_bench_bitcoin_SOURCES = \ bench/verification.cpp \ bench/crypto_hash.cpp \ bench/base58.cpp \ + bench/lockedpool.cpp \ bench/perf.cpp \ bench/perf.h \ bench/prevector_destructor.cpp diff --git a/src/bench/lockedpool.cpp b/src/bench/lockedpool.cpp new file mode 100644 index 000000000..5df5b1ac6 --- /dev/null +++ b/src/bench/lockedpool.cpp @@ -0,0 +1,47 @@ +// Copyright (c) 2016 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.h" + +#include "support/lockedpool.h" + +#include +#include + +#define ASIZE 2048 +#define BITER 5000 +#define MSIZE 2048 + +static void LockedPool(benchmark::State& state) +{ + void *synth_base = reinterpret_cast(0x08000000); + const size_t synth_size = 1024*1024; + Arena b(synth_base, synth_size, 16); + + std::vector addr; + for (int x=0; x> 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(LockedPool); +