@@ -55,6 +55,24 @@ template <class T> void bench_fast_with_alloc(T &data) {
5555 }));
5656}
5757
58+
59+ template <class T > void bench_fast_with_assign (T &data) {
60+ std::string json;
61+ simdjson::json_builder::to_json (data, json);
62+ size_t output_volume = json.size ();
63+ printf (" # output volume: %zu bytes\n " , output_volume);
64+
65+ volatile size_t measured_volume = 0 ;
66+ pretty_print (sizeof (data), output_volume, " bench_fast_with_assign" ,
67+ bench ([&data, &measured_volume, &output_volume, &json]() {
68+ simdjson::json_builder::to_json (data, json);
69+ measured_volume = json.size ();
70+ if (measured_volume != output_volume) {
71+ printf (" mismatch\n " );
72+ }
73+ }));
74+ }
75+
5876void bench_nlohmann (TwitterData &data) {
5977 std::string output = nlohmann_serialize (data);
6078 size_t output_volume = output.size ();
@@ -190,9 +208,10 @@ int main() {
190208 auto json_value = parser.parse ();
191209 TwitterData my_struct;
192210 bench_nlohmann (my_struct);
193- // simpleparser::json_builder::from_json(json_value, my_struct);
211+ simpleparser::json_builder::from_json (json_value, my_struct);
194212 bench_fast_simpler (my_struct);
195213 bench_fast_with_alloc (my_struct);
214+ bench_fast_with_assign (my_struct);
196215#if SIMDJSON_BENCH_CPP_REFLECT
197216 bench_reflect_cpp (my_struct);
198217#endif
0 commit comments