Changeset View
Changeset View
Standalone View
Standalone View
src/bench/lockedpool.cpp
// Copyright (c) 2016 The Bitcoin Core developers | // Copyright (c) 2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include "bench.h" | #include "bench.h" | ||||
#include "support/lockedpool.h" | #include "support/lockedpool.h" | ||||
#include <iostream> | #include <iostream> | ||||
#include <vector> | #include <vector> | ||||
#define ASIZE 2048 | #define ASIZE 2048 | ||||
#define BITER 5000 | #define BITER 5000 | ||||
#define MSIZE 2048 | #define MSIZE 2048 | ||||
static void LockedPool(benchmark::State &state) { | static void BenchLockedPool(benchmark::State &state) { | ||||
void *synth_base = reinterpret_cast<void *>(0x08000000); | void *synth_base = reinterpret_cast<void *>(0x08000000); | ||||
const size_t synth_size = 1024 * 1024; | const size_t synth_size = 1024 * 1024; | ||||
Arena b(synth_base, synth_size, 16); | Arena b(synth_base, synth_size, 16); | ||||
std::vector<void *> addr; | std::vector<void *> addr; | ||||
for (int x = 0; x < ASIZE; ++x) | for (int x = 0; x < ASIZE; ++x) | ||||
addr.push_back(0); | addr.push_back(0); | ||||
uint32_t s = 0x12345678; | uint32_t s = 0x12345678; | ||||
Show All 11 Lines | while (state.KeepRunning()) { | ||||
if (lsb) s ^= 0xf00f00f0; // LFSR period 0xf7ffffe0 | if (lsb) s ^= 0xf00f00f0; // LFSR period 0xf7ffffe0 | ||||
} | } | ||||
} | } | ||||
for (void *ptr : addr) | for (void *ptr : addr) | ||||
b.free(ptr); | b.free(ptr); | ||||
addr.clear(); | addr.clear(); | ||||
} | } | ||||
BENCHMARK(LockedPool); | BENCHMARK(BenchLockedPool); |