@@ -80,16 +80,16 @@ static void ondemand_tweets(State &state) {
80
80
tweet_count += tweets.size ();
81
81
}
82
82
// Gigabyte: https://en.wikipedia.org/wiki/Gigabyte
83
- state.counters [" Gigabytes " ] = benchmark::Counter (
83
+ state.counters [" bytes " ] = benchmark::Counter (
84
84
double (byte_count), benchmark::Counter::kIsRate ,
85
85
benchmark::Counter::OneK::kIs1000 ); // For GiB : kIs1024
86
86
state.counters [" docs" ] = Counter (double (state.iterations ()), benchmark::Counter::kIsRate );
87
87
state.counters [" tweets" ] = Counter (double (tweet_count), benchmark::Counter::kIsRate );
88
88
}
89
89
90
- BENCHMARK (ondemand_tweets)->Repetitions (REPETITIONS)-> ComputeStatistics(" max" , [](const std::vector<double >& v) -> double {
90
+ BENCHMARK (ondemand_tweets)->ComputeStatistics (" max" , [](const std::vector<double >& v) -> double {
91
91
return *(std::max_element (std::begin (v), std::end (v)));
92
- })-> DisplayAggregatesOnly ( true ) ;
92
+ });
93
93
94
94
} // namespace ondemand_bench
95
95
@@ -165,16 +165,16 @@ static void iter_tweets(State &state) {
165
165
tweet_count += tweets.size ();
166
166
}
167
167
// Gigabyte: https://en.wikipedia.org/wiki/Gigabyte
168
- state.counters [" Gigabytes " ] = benchmark::Counter (
168
+ state.counters [" bytes " ] = benchmark::Counter (
169
169
double (byte_count), benchmark::Counter::kIsRate ,
170
170
benchmark::Counter::OneK::kIs1000 ); // For GiB : kIs1024
171
171
state.counters [" docs" ] = Counter (double (state.iterations ()), benchmark::Counter::kIsRate );
172
172
state.counters [" tweets" ] = Counter (double (tweet_count), benchmark::Counter::kIsRate );
173
173
}
174
174
175
- BENCHMARK (iter_tweets)->Repetitions (REPETITIONS)-> ComputeStatistics(" max" , [](const std::vector<double >& v) -> double {
175
+ BENCHMARK (iter_tweets)->ComputeStatistics (" max" , [](const std::vector<double >& v) -> double {
176
176
return *(std::max_element (std::begin (v), std::end (v)));
177
- })-> DisplayAggregatesOnly ( true ) ;
177
+ });
178
178
179
179
} // namespace iter_bench
180
180
@@ -204,15 +204,15 @@ static void sax_tweets(State &state) {
204
204
tweets += reader.tweets .size ();
205
205
}
206
206
// Gigabyte: https://en.wikipedia.org/wiki/Gigabyte
207
- state.counters [" Gigabytes " ] = benchmark::Counter (
207
+ state.counters [" bytes " ] = benchmark::Counter (
208
208
double (bytes), benchmark::Counter::kIsRate ,
209
209
benchmark::Counter::OneK::kIs1000 ); // For GiB : kIs1024
210
210
state.counters [" docs" ] = Counter (double (state.iterations ()), benchmark::Counter::kIsRate );
211
211
state.counters [" tweets" ] = Counter (double (tweets), benchmark::Counter::kIsRate );
212
212
}
213
- BENCHMARK (sax_tweets)->Repetitions(REPETITIONS)-> ComputeStatistics(" max" , [](const std::vector<double >& v) -> double {
213
+ BENCHMARK (sax_tweets)->ComputeStatistics(" max" , [](const std::vector<double >& v) -> double {
214
214
return *(std::max_element (std::begin (v), std::end (v)));
215
- })-> DisplayAggregatesOnly ( true ) ;
215
+ });
216
216
217
217
#endif // SIMDJSON_IMPLEMENTATION_HASWELL
218
218
@@ -260,17 +260,17 @@ static void dom_tweets(State &state) {
260
260
num_tweets += tweets.size ();
261
261
}
262
262
// Gigabyte: https://en.wikipedia.org/wiki/Gigabyte
263
- state.counters [" Gigabytes " ] = benchmark::Counter (
263
+ state.counters [" bytes " ] = benchmark::Counter (
264
264
double (bytes), benchmark::Counter::kIsRate ,
265
265
benchmark::Counter::OneK::kIs1000 ); // For GiB : kIs1024
266
266
state.counters [" docs" ] = Counter (double (state.iterations ()), benchmark::Counter::kIsRate );
267
267
state.counters [" tweets" ] = Counter (double (num_tweets), benchmark::Counter::kIsRate );
268
268
}
269
- BENCHMARK (dom_tweets)->Repetitions(REPETITIONS)-> ComputeStatistics(" max" , [](const std::vector<double >& v) -> double {
269
+ BENCHMARK (dom_tweets)->ComputeStatistics(" max" , [](const std::vector<double >& v) -> double {
270
270
return *(std::max_element (std::begin (v), std::end (v)));
271
- })-> DisplayAggregatesOnly ( true ) ;
271
+ });
272
272
273
- static void dom_parse (State &state) {
273
+ static void parse_tweets (State &state) {
274
274
// Load twitter.json to a buffer
275
275
padded_string json;
276
276
if (auto error = padded_string::load (TWITTER_JSON).get (json)) { cerr << error << endl; return ; }
@@ -286,14 +286,14 @@ static void dom_parse(State &state) {
286
286
bytes += json.size ();
287
287
}
288
288
// Gigabyte: https://en.wikipedia.org/wiki/Gigabyte
289
- state.counters [" Gigabytes " ] = benchmark::Counter (
289
+ state.counters [" bytes " ] = benchmark::Counter (
290
290
double (bytes), benchmark::Counter::kIsRate ,
291
291
benchmark::Counter::OneK::kIs1000 ); // For GiB : kIs1024
292
292
state.counters [" docs" ] = Counter (double (state.iterations ()), benchmark::Counter::kIsRate );
293
293
}
294
- BENCHMARK (dom_parse)->Repetitions(REPETITIONS )->ComputeStatistics(" max" , [](const std::vector<double >& v) -> double {
294
+ BENCHMARK (parse_tweets )->ComputeStatistics(" max" , [](const std::vector<double >& v) -> double {
295
295
return *(std::max_element (std::begin (v), std::end (v)));
296
- })-> DisplayAggregatesOnly ( true ) ;
296
+ });
297
297
298
298
299
299
/* *******************
@@ -346,6 +346,7 @@ static void dom_largerandom(State &state) {
346
346
347
347
// Read
348
348
size_t bytes = 0 ;
349
+ size_t points = 0 ;
349
350
simdjson::error_code error;
350
351
for (SIMDJSON_UNUSED auto _ : state) {
351
352
std::vector<my_point> container;
@@ -358,19 +359,21 @@ static void dom_largerandom(State &state) {
358
359
container.emplace_back (my_point{point[" x" ], point[" y" ], point[" z" ]});
359
360
}
360
361
bytes += json.size ();
362
+ points += container.size ();
361
363
benchmark::DoNotOptimize (container.data ());
362
-
363
364
}
365
+
364
366
// Gigabyte: https://en.wikipedia.org/wiki/Gigabyte
365
- state.counters [" Gigabytes " ] = benchmark::Counter (
367
+ state.counters [" bytes " ] = benchmark::Counter (
366
368
double (bytes), benchmark::Counter::kIsRate ,
367
369
benchmark::Counter::OneK::kIs1000 ); // For GiB : kIs1024
368
370
state.counters [" docs" ] = Counter (double (state.iterations ()), benchmark::Counter::kIsRate );
371
+ state.counters [" points" ] = Counter (double (points), benchmark::Counter::kIsRate );
369
372
}
370
373
371
- BENCHMARK (dom_largerandom)->Repetitions(REPETITIONS)-> ComputeStatistics(" max" , [](const std::vector<double >& v) -> double {
374
+ BENCHMARK (dom_largerandom)->ComputeStatistics(" max" , [](const std::vector<double >& v) -> double {
372
375
return *(std::max_element (std::begin (v), std::end (v)));
373
- })-> DisplayAggregatesOnly ( true ) ;
376
+ });
374
377
375
378
#if SIMDJSON_IMPLEMENTATION_HASWELL
376
379
@@ -391,27 +394,29 @@ static void ondemand_largerandom(State &state) {
391
394
392
395
// Read
393
396
size_t bytes = 0 ;
397
+ size_t points = 0 ;
394
398
for (SIMDJSON_UNUSED auto _ : state) {
395
399
std::vector<my_point> container;
396
400
for (ondemand::object point : parser.parse (json)) {
397
401
container.emplace_back (my_point{(*point).value (), (*++point).value (), (*++point).value ()});
398
402
}
399
403
bytes += json.size ();
404
+ points += container.size ();
400
405
benchmark::DoNotOptimize (container.data ());
401
-
402
406
}
403
407
// Gigabyte: https://en.wikipedia.org/wiki/Gigabyte
404
- state.counters [" Gigabytes " ] = benchmark::Counter (
408
+ state.counters [" bytes " ] = benchmark::Counter (
405
409
double (bytes), benchmark::Counter::kIsRate ,
406
410
benchmark::Counter::OneK::kIs1000 ); // For GiB : kIs1024
407
411
state.counters [" docs" ] = Counter (double (state.iterations ()), benchmark::Counter::kIsRate );
412
+ state.counters [" points" ] = Counter (double (points), benchmark::Counter::kIsRate );
408
413
}
409
414
410
415
SIMDJSON_UNTARGET_REGION
411
416
412
- BENCHMARK (ondemand_largerandom)->Repetitions(REPETITIONS)-> ComputeStatistics(" max" , [](const std::vector<double >& v) -> double {
417
+ BENCHMARK (ondemand_largerandom)->ComputeStatistics(" max" , [](const std::vector<double >& v) -> double {
413
418
return *(std::max_element (std::begin (v), std::end (v)));
414
- })-> DisplayAggregatesOnly ( true ) ;
419
+ });
415
420
416
421
SIMDJSON_TARGET_HASWELL
417
422
@@ -440,6 +445,7 @@ static void iter_largerandom(State &state) {
440
445
441
446
// Read
442
447
size_t bytes = 0 ;
448
+ size_t points = 0 ;
443
449
for (SIMDJSON_UNUSED auto _ : state) {
444
450
std::vector<my_point> container;
445
451
auto doc = parser.parse (json);
@@ -452,20 +458,22 @@ static void iter_largerandom(State &state) {
452
458
} while (iter.has_next_element ());
453
459
}
454
460
bytes += json.size ();
461
+ points += container.size ();
455
462
benchmark::DoNotOptimize (container.data ());
456
463
}
457
464
// Gigabyte: https://en.wikipedia.org/wiki/Gigabyte
458
- state.counters [" Gigabytes " ] = benchmark::Counter (
465
+ state.counters [" bytes " ] = benchmark::Counter (
459
466
double (bytes), benchmark::Counter::kIsRate ,
460
467
benchmark::Counter::OneK::kIs1000 ); // For GiB : kIs1024
461
468
state.counters [" docs" ] = Counter (double (state.iterations ()), benchmark::Counter::kIsRate );
469
+ state.counters [" points" ] = Counter (double (points), benchmark::Counter::kIsRate );
462
470
}
463
471
464
472
SIMDJSON_UNTARGET_REGION
465
473
466
- BENCHMARK (iter_largerandom)->Repetitions(REPETITIONS)-> ComputeStatistics(" max" , [](const std::vector<double >& v) -> double {
474
+ BENCHMARK (iter_largerandom)->ComputeStatistics(" max" , [](const std::vector<double >& v) -> double {
467
475
return *(std::max_element (std::begin (v), std::end (v)));
468
- })-> DisplayAggregatesOnly ( true ) ;
476
+ });
469
477
470
478
/* **
471
479
* Next we are going to code the SAX approach.
@@ -485,27 +493,22 @@ struct sax_point_reader_visitor {
485
493
}
486
494
487
495
simdjson_really_inline error_code visit_document_start (json_iterator &) { return SUCCESS; }
488
- simdjson_really_inline error_code visit_object_start (json_iterator &) { return SUCCESS; }
489
- simdjson_really_inline error_code visit_key (json_iterator &, const uint8_t *key) {
490
- switch (key[0 ]) {
491
- case ' x' :
492
- idx = 0 ;
493
- break ;
494
- case ' y' :
495
- idx = 2 ;
496
- break ;
497
- case ' z' :
498
- idx = 3 ;
499
- break ;
500
- }
496
+ simdjson_really_inline error_code visit_object_start (json_iterator &) {
497
+ idx = 0 ;
498
+ return SUCCESS;
499
+ }
500
+ simdjson_really_inline error_code visit_key (json_iterator &, const uint8_t *) {
501
501
return SUCCESS;
502
502
}
503
503
simdjson_really_inline error_code visit_primitive (json_iterator &, const uint8_t *value) {
504
- return numberparsing::parse_double (value).get (buffer[idx]);
504
+ return numberparsing::parse_double (value).get (buffer[idx++ ]);
505
505
}
506
506
simdjson_really_inline error_code visit_array_start (json_iterator &) { return SUCCESS; }
507
507
simdjson_really_inline error_code visit_array_end (json_iterator &) { return SUCCESS; }
508
- simdjson_really_inline error_code visit_object_end (json_iterator &) { return SUCCESS; }
508
+ simdjson_really_inline error_code visit_object_end (json_iterator &) {
509
+ points.emplace_back (my_point{buffer[0 ], buffer[1 ], buffer[2 ]});
510
+ return SUCCESS;
511
+ }
509
512
simdjson_really_inline error_code visit_document_end (json_iterator &) { return SUCCESS; }
510
513
simdjson_really_inline error_code visit_empty_array (json_iterator &) { return SUCCESS; }
511
514
simdjson_really_inline error_code visit_empty_object (json_iterator &) { return SUCCESS; }
@@ -583,20 +586,23 @@ static void sax_largerandom(State &state) {
583
586
584
587
// Read
585
588
size_t bytes = 0 ;
589
+ size_t points = 0 ;
586
590
for (SIMDJSON_UNUSED auto _ : state) {
587
591
if (auto error = reader.read_points (json)) { throw error; }
588
592
bytes += json.size ();
593
+ points += reader.points .size ();
589
594
benchmark::DoNotOptimize (reader.points .data ());
590
595
}
591
596
// Gigabyte: https://en.wikipedia.org/wiki/Gigabyte
592
- state.counters [" Gigabytes " ] = benchmark::Counter (
597
+ state.counters [" bytes " ] = benchmark::Counter (
593
598
double (bytes), benchmark::Counter::kIsRate ,
594
599
benchmark::Counter::OneK::kIs1000 ); // For GiB : kIs1024
595
600
state.counters [" docs" ] = Counter (double (state.iterations ()), benchmark::Counter::kIsRate );
601
+ state.counters [" points" ] = Counter (double (points), benchmark::Counter::kIsRate );
596
602
}
597
- BENCHMARK (sax_largerandom)->Repetitions(REPETITIONS)-> ComputeStatistics(" max" , [](const std::vector<double >& v) -> double {
603
+ BENCHMARK (sax_largerandom)->ComputeStatistics(" max" , [](const std::vector<double >& v) -> double {
598
604
return *(std::max_element (std::begin (v), std::end (v)));
599
- })-> DisplayAggregatesOnly ( true ) ;
605
+ });
600
606
601
607
#endif // SIMDJSON_IMPLEMENTATION_HASWELL
602
608
0 commit comments