Skip to content

Commit c3dec1a

Browse files
committed
Default SIMDJSON_GOOGLE_BENCHMARKS to ON.
1 parent 5d7a84f commit c3dec1a

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

benchmark/bench_dom_api.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ BENCHMARK(twitter_image_sizes);
365365
static void error_code_twitter_count(State& state) noexcept {
366366
// Prints the number of results in twitter.json
367367
dom::parser parser;
368-
dom::element doc = parser.load(TWITTER_JSON);
368+
auto [doc, error1] = parser.load(TWITTER_JSON);
369+
if (error1) { return; }
369370
for (UNUSED auto _ : state) {
370371
auto [value, error] = doc["search_metadata"]["count"].get<uint64_t>();
371372
if (error) { return; }
@@ -377,7 +378,8 @@ BENCHMARK(error_code_twitter_count);
377378
static void error_code_twitter_default_profile(State& state) noexcept {
378379
// Count unique users with a default profile.
379380
dom::parser parser;
380-
dom::element doc = parser.load(TWITTER_JSON);
381+
auto [doc, error1] = parser.load(TWITTER_JSON);
382+
if (error1) { std::cerr << error1 << std::endl; return; }
381383
for (UNUSED auto _ : state) {
382384
set<string_view> default_users;
383385

@@ -404,7 +406,8 @@ SIMDJSON_PUSH_DISABLE_WARNINGS
404406
SIMDJSON_DISABLE_DEPRECATED_WARNING
405407
static void iterator_twitter_default_profile(State& state) {
406408
// Count unique users with a default profile.
407-
padded_string json = padded_string::load(TWITTER_JSON);
409+
auto [json, error1] = padded_string::load(TWITTER_JSON);
410+
if (error1) { std::cerr << error1 << std::endl; return; }
408411
ParsedJson pj = build_parsed_json(json);
409412
for (UNUSED auto _ : state) {
410413
set<string_view> default_users;
@@ -444,7 +447,8 @@ BENCHMARK(iterator_twitter_default_profile);
444447
static void error_code_twitter_image_sizes(State& state) noexcept {
445448
// Count unique image sizes
446449
dom::parser parser;
447-
dom::element doc = parser.load(TWITTER_JSON);
450+
auto [doc, error1] = parser.load(TWITTER_JSON);
451+
if (error1) { std::cerr << error1 << std::endl; return; }
448452
for (UNUSED auto _ : state) {
449453
set<tuple<uint64_t, uint64_t>> image_sizes;
450454
auto [statuses, error] = doc["statuses"].get<dom::array>();
@@ -473,7 +477,8 @@ SIMDJSON_PUSH_DISABLE_WARNINGS
473477
SIMDJSON_DISABLE_DEPRECATED_WARNING
474478
static void iterator_twitter_image_sizes(State& state) {
475479
// Count unique image sizes
476-
padded_string json = padded_string::load(TWITTER_JSON);
480+
auto [json, error1] = padded_string::load(TWITTER_JSON);
481+
if (error1) { std::cerr << error1 << std::endl; return; }
477482
ParsedJson pj = build_parsed_json(json);
478483
for (UNUSED auto _ : state) {
479484
set<tuple<uint64_t, uint64_t>> image_sizes;
@@ -531,7 +536,8 @@ BENCHMARK(iterator_twitter_image_sizes);
531536

532537
static void print_json(State& state) noexcept {
533538
// Prints the number of results in twitter.json
534-
padded_string json = get_corpus(TWITTER_JSON);
539+
auto [json, error1] = padded_string::load(TWITTER_JSON);
540+
if (error1) { std::cerr << error1 << std::endl; return; }
535541
dom::parser parser;
536542
if (int error = json_parse(json, parser); error != SUCCESS) { cerr << error_message(error) << endl; return; }
537543
for (UNUSED auto _ : state) {

benchmark/bench_parse_call.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ static void parser_parse_error_code(State& state) {
104104
}
105105
}
106106
BENCHMARK(parser_parse_error_code);
107+
108+
#if SIMDJSON_EXCEPTIONS
109+
107110
static void parser_parse_exception(State& state) {
108111
dom::parser parser;
109112
if (parser.allocate(EMPTY_ARRAY.length())) { return; }
@@ -118,6 +121,8 @@ static void parser_parse_exception(State& state) {
118121
}
119122
BENCHMARK(parser_parse_exception);
120123

124+
#endif // SIMDJSON_EXCEPTIONS
125+
121126
SIMDJSON_PUSH_DISABLE_WARNINGS
122127
SIMDJSON_DISABLE_DEPRECATED_WARNING
123128
static void build_parsed_json(State& state) {
@@ -127,6 +132,7 @@ static void build_parsed_json(State& state) {
127132
}
128133
}
129134
SIMDJSON_POP_DISABLE_WARNINGS
135+
130136
BENCHMARK(build_parsed_json);
131137
static void document_parse_error_code(State& state) {
132138
for (UNUSED auto _ : state) {
@@ -136,6 +142,9 @@ static void document_parse_error_code(State& state) {
136142
}
137143
}
138144
BENCHMARK(document_parse_error_code);
145+
146+
#if SIMDJSON_EXCEPTIONS
147+
139148
static void document_parse_exception(State& state) {
140149
for (UNUSED auto _ : state) {
141150
try {
@@ -149,4 +158,6 @@ static void document_parse_exception(State& state) {
149158
}
150159
BENCHMARK(document_parse_exception);
151160

161+
#endif // SIMDJSON_EXCEPTIONS
162+
152163
BENCHMARK_MAIN();

simdjson-flags.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ else()
1111
option(SIMDJSON_COMPETITION "Compile competitive benchmarks" ON)
1212
option(SIMDJSON_USE_LIBCPP "Use the libc++ library" OFF)
1313
endif()
14-
option(SIMDJSON_GOOGLE_BENCHMARKS "compile the Google Benchmark benchmarks" OFF)
14+
option(SIMDJSON_GOOGLE_BENCHMARKS "compile the Google Benchmark benchmarks" ON)
1515

1616
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake")
1717

0 commit comments

Comments
 (0)