mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-12 21:02:38 -03:00
78dae8cacc
3fc20632a3
qt: Set BLOCK_CHAIN_SIZE = 220 (DrahtBot)2b6a2f4a28
Regenerate manpages (DrahtBot)eb7daf4d60
Update copyright headers to 2018 (DrahtBot) Pull request description: Some trivial maintenance to avoid having to do it again after the 0.17 branch off. (The scripts to do this are in `./contrib/`) Tree-SHA512: 16b2af45e0351b1c691c5311d48025dc6828079e98c2aa2e600dc5910ee8aa01858ca6c356538150dc46fe14c8819ed8ec8e4ec9a0f682b9950dd41bc50518fa
105 lines
3 KiB
C++
105 lines
3 KiB
C++
// Copyright (c) 2015-2018 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 <compat.h>
|
|
#include <prevector.h>
|
|
#include <serialize.h>
|
|
#include <streams.h>
|
|
|
|
#include <bench/bench.h>
|
|
|
|
struct nontrivial_t {
|
|
int x;
|
|
nontrivial_t() :x(-1) {}
|
|
ADD_SERIALIZE_METHODS
|
|
template <typename Stream, typename Operation>
|
|
inline void SerializationOp(Stream& s, Operation ser_action) {READWRITE(x);}
|
|
};
|
|
static_assert(!IS_TRIVIALLY_CONSTRUCTIBLE<nontrivial_t>::value,
|
|
"expected nontrivial_t to not be trivially constructible");
|
|
|
|
typedef unsigned char trivial_t;
|
|
static_assert(IS_TRIVIALLY_CONSTRUCTIBLE<trivial_t>::value,
|
|
"expected trivial_t to be trivially constructible");
|
|
|
|
template <typename T>
|
|
static void PrevectorDestructor(benchmark::State& state)
|
|
{
|
|
while (state.KeepRunning()) {
|
|
for (auto x = 0; x < 1000; ++x) {
|
|
prevector<28, T> t0;
|
|
prevector<28, T> t1;
|
|
t0.resize(28);
|
|
t1.resize(29);
|
|
}
|
|
}
|
|
}
|
|
|
|
template <typename T>
|
|
static void PrevectorClear(benchmark::State& state)
|
|
{
|
|
|
|
while (state.KeepRunning()) {
|
|
for (auto x = 0; x < 1000; ++x) {
|
|
prevector<28, T> t0;
|
|
prevector<28, T> t1;
|
|
t0.resize(28);
|
|
t0.clear();
|
|
t1.resize(29);
|
|
t1.clear();
|
|
}
|
|
}
|
|
}
|
|
|
|
template <typename T>
|
|
static void PrevectorResize(benchmark::State& state)
|
|
{
|
|
while (state.KeepRunning()) {
|
|
prevector<28, T> t0;
|
|
prevector<28, T> t1;
|
|
for (auto x = 0; x < 1000; ++x) {
|
|
t0.resize(28);
|
|
t0.resize(0);
|
|
t1.resize(29);
|
|
t1.resize(0);
|
|
}
|
|
}
|
|
}
|
|
|
|
template <typename T>
|
|
static void PrevectorDeserialize(benchmark::State& state)
|
|
{
|
|
CDataStream s0(SER_NETWORK, 0);
|
|
prevector<28, T> t0;
|
|
t0.resize(28);
|
|
for (auto x = 0; x < 900; ++x) {
|
|
s0 << t0;
|
|
}
|
|
t0.resize(100);
|
|
for (auto x = 0; x < 101; ++x) {
|
|
s0 << t0;
|
|
}
|
|
while (state.KeepRunning()) {
|
|
prevector<28, T> t1;
|
|
for (auto x = 0; x < 1000; ++x) {
|
|
s0 >> t1;
|
|
}
|
|
s0.Init(SER_NETWORK, 0);
|
|
}
|
|
}
|
|
|
|
#define PREVECTOR_TEST(name, nontrivops, trivops) \
|
|
static void Prevector ## name ## Nontrivial(benchmark::State& state) { \
|
|
Prevector ## name<nontrivial_t>(state); \
|
|
} \
|
|
BENCHMARK(Prevector ## name ## Nontrivial, nontrivops); \
|
|
static void Prevector ## name ## Trivial(benchmark::State& state) { \
|
|
Prevector ## name<trivial_t>(state); \
|
|
} \
|
|
BENCHMARK(Prevector ## name ## Trivial, trivops);
|
|
|
|
PREVECTOR_TEST(Clear, 28300, 88600)
|
|
PREVECTOR_TEST(Destructor, 28800, 88900)
|
|
PREVECTOR_TEST(Resize, 28900, 90300)
|
|
PREVECTOR_TEST(Deserialize, 6800, 52000)
|