4
4
5
5
#include < compat.h>
6
6
#include < prevector.h>
7
+ #include < serialize.h>
8
+ #include < streams.h>
7
9
8
10
#include < bench/bench.h>
9
11
10
12
struct nontrivial_t {
11
13
int x;
12
14
nontrivial_t () :x(-1 ) {}
15
+ ADD_SERIALIZE_METHODS
16
+ template <typename Stream, typename Operation>
17
+ inline void SerializationOp (Stream& s, Operation ser_action) {READWRITE (x);}
13
18
};
14
19
static_assert (!IS_TRIVIALLY_CONSTRUCTIBLE<nontrivial_t >::value,
15
20
" expected nontrivial_t to not be trivially constructible" );
@@ -62,6 +67,28 @@ static void PrevectorResize(benchmark::State& state)
62
67
}
63
68
}
64
69
70
+ template <typename T>
71
+ static void PrevectorDeserialize (benchmark::State& state)
72
+ {
73
+ CDataStream s0 (SER_NETWORK, 0 );
74
+ prevector<28 , T> t0;
75
+ t0.resize (28 );
76
+ for (auto x = 0 ; x < 900 ; ++x) {
77
+ s0 << t0;
78
+ }
79
+ t0.resize (100 );
80
+ for (auto x = 0 ; x < 101 ; ++x) {
81
+ s0 << t0;
82
+ }
83
+ while (state.KeepRunning ()) {
84
+ prevector<28 , T> t1;
85
+ for (auto x = 0 ; x < 1000 ; ++x) {
86
+ s0 >> t1;
87
+ }
88
+ s0.Init (SER_NETWORK, 0 );
89
+ }
90
+ }
91
+
65
92
#define PREVECTOR_TEST (name, nontrivops, trivops ) \
66
93
static void Prevector ## name ## Nontrivial(benchmark::State& state) { \
67
94
Prevector ## name<nontrivial_t >(state); \
@@ -75,3 +102,4 @@ static void PrevectorResize(benchmark::State& state)
75
102
PREVECTOR_TEST (Clear, 28300 , 88600 )
76
103
PREVECTOR_TEST(Destructor, 28800 , 88900 )
77
104
PREVECTOR_TEST(Resize, 28900 , 90300 )
105
+ PREVECTOR_TEST(Deserialize, 6800 , 52000 )
0 commit comments