mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Merge #13711: [bench] Add benchmark for unserialize prevector
46340b3337 [bench] Add benchmark for unserialize prevector (Akio Nakamura) Pull request description: This PR adds benchmarks for the unserialization of the prevector. Note: Separated from #12324. Tree-SHA512: c055a283328cc2634c01eb60f26604a8665939bbf77d367b6ba6b4e01e77d4511fab69cc3ddb1e62969adb3c48752ed870f45ceba153eee192302601341e18a7
This commit is contained in:
parent
e1e303b179
commit
c59dcbba59
@ -4,12 +4,17 @@
|
|||||||
|
|
||||||
#include <compat.h>
|
#include <compat.h>
|
||||||
#include <prevector.h>
|
#include <prevector.h>
|
||||||
|
#include <serialize.h>
|
||||||
|
#include <streams.h>
|
||||||
|
|
||||||
#include <bench/bench.h>
|
#include <bench/bench.h>
|
||||||
|
|
||||||
struct nontrivial_t {
|
struct nontrivial_t {
|
||||||
int x;
|
int x;
|
||||||
nontrivial_t() :x(-1) {}
|
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,
|
static_assert(!IS_TRIVIALLY_CONSTRUCTIBLE<nontrivial_t>::value,
|
||||||
"expected nontrivial_t to not be trivially constructible");
|
"expected nontrivial_t to not be trivially constructible");
|
||||||
@ -55,6 +60,28 @@ void PrevectorResize(benchmark::State& state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) \
|
#define PREVECTOR_TEST(name, nontrivops, trivops) \
|
||||||
static void Prevector ## name ## Nontrivial(benchmark::State& state) { \
|
static void Prevector ## name ## Nontrivial(benchmark::State& state) { \
|
||||||
Prevector ## name<nontrivial_t>(state); \
|
Prevector ## name<nontrivial_t>(state); \
|
||||||
@ -68,6 +95,7 @@ void PrevectorResize(benchmark::State& state)
|
|||||||
PREVECTOR_TEST(Clear, 80 * 1000 * 1000, 70 * 1000 * 1000)
|
PREVECTOR_TEST(Clear, 80 * 1000 * 1000, 70 * 1000 * 1000)
|
||||||
PREVECTOR_TEST(Destructor, 800 * 1000 * 1000, 800 * 1000 * 1000)
|
PREVECTOR_TEST(Destructor, 800 * 1000 * 1000, 800 * 1000 * 1000)
|
||||||
PREVECTOR_TEST(Resize, 80 * 1000 * 1000, 70 * 1000 * 1000)
|
PREVECTOR_TEST(Resize, 80 * 1000 * 1000, 70 * 1000 * 1000)
|
||||||
|
PREVECTOR_TEST(Deserialize, 6800, 52000)
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user