diff --git a/src/bench/prevector.cpp b/src/bench/prevector.cpp index 09c702084..7986d0da7 100644 --- a/src/bench/prevector.cpp +++ b/src/bench/prevector.cpp @@ -4,12 +4,17 @@ #include #include +#include +#include #include struct nontrivial_t { int x; nontrivial_t() :x(-1) {} + ADD_SERIALIZE_METHODS + template + inline void SerializationOp(Stream& s, Operation ser_action) {READWRITE(x);} }; static_assert(!IS_TRIVIALLY_CONSTRUCTIBLE::value, "expected nontrivial_t to not be trivially constructible"); @@ -62,6 +67,28 @@ static void PrevectorResize(benchmark::State& state) } } +template +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(state); \ @@ -75,3 +102,4 @@ static void PrevectorResize(benchmark::State& state) PREVECTOR_TEST(Clear, 28300, 88600) PREVECTOR_TEST(Destructor, 28800, 88900) PREVECTOR_TEST(Resize, 28900, 90300) +PREVECTOR_TEST(Deserialize, 6800, 52000)