@@ -6,18 +6,16 @@ using namespace simdjson;
66using namespace benchmark ;
77using namespace std ;
88
9- #ifndef JSON_TEST_PATH
10- #define JSON_TEST_PATH " jsonexamples/twitter.json"
11- #endif
12-
139const padded_string EMPTY_ARRAY (" []" , 2 );
1410
11+ const char *TWITTER_JSON = SIMDJSON_BENCHMARK_DATA_DIR " " ;
12+
1513#if SIMDJSON_EXCEPTIONS
1614
1715static void twitter_count (State& state) {
1816 // Prints the number of results in twitter.json
1917 dom::parser parser;
20- dom::element doc = parser.load (JSON_TEST_PATH );
18+ dom::element doc = parser.load (TWITTER_JSON );
2119 for (auto _ : state) {
2220 uint64_t result_count = doc[" search_metadata" ][" count" ];
2321 if (result_count != 100 ) { return ; }
@@ -29,7 +27,7 @@ SIMDJSON_PUSH_DISABLE_WARNINGS
2927SIMDJSON_DISABLE_DEPRECATED_WARNING
3028static void iterator_twitter_count (State& state) {
3129 // Prints the number of results in twitter.json
32- padded_string json = padded_string::load (JSON_TEST_PATH );
30+ padded_string json = padded_string::load (TWITTER_JSON );
3331 ParsedJson pj = build_parsed_json (json);
3432 for (auto _ : state) {
3533 ParsedJson::Iterator iter (pj);
@@ -48,7 +46,7 @@ SIMDJSON_POP_DISABLE_WARNINGS
4846static void twitter_default_profile (State& state) {
4947 // Count unique users with a default profile.
5048 dom::parser parser;
51- dom::element doc = parser.load (JSON_TEST_PATH );
49+ dom::element doc = parser.load (TWITTER_JSON );
5250 for (auto _ : state) {
5351 set<string_view> default_users;
5452 for (dom::object tweet : doc[" statuses" ].get <dom::array>()) {
@@ -65,7 +63,7 @@ BENCHMARK(twitter_default_profile);
6563static void twitter_image_sizes (State& state) {
6664 // Count unique image sizes
6765 dom::parser parser;
68- dom::element doc = parser.load (JSON_TEST_PATH );
66+ dom::element doc = parser.load (TWITTER_JSON );
6967 for (auto _ : state) {
7068 set<tuple<uint64_t , uint64_t >> image_sizes;
7169 for (dom::object tweet : doc[" statuses" ].get <dom::array>()) {
@@ -88,7 +86,7 @@ BENCHMARK(twitter_image_sizes);
8886static void error_code_twitter_count (State& state) noexcept {
8987 // Prints the number of results in twitter.json
9088 dom::parser parser;
91- dom::element doc = parser.load (JSON_TEST_PATH );
89+ dom::element doc = parser.load (TWITTER_JSON );
9290 for (auto _ : state) {
9391 auto [value, error] = doc[" search_metadata" ][" count" ].get <uint64_t >();
9492 if (error) { return ; }
@@ -100,7 +98,7 @@ BENCHMARK(error_code_twitter_count);
10098static void error_code_twitter_default_profile (State& state) noexcept {
10199 // Count unique users with a default profile.
102100 dom::parser parser;
103- dom::element doc = parser.load (JSON_TEST_PATH );
101+ dom::element doc = parser.load (TWITTER_JSON );
104102 for (auto _ : state) {
105103 set<string_view> default_users;
106104
@@ -127,7 +125,7 @@ SIMDJSON_PUSH_DISABLE_WARNINGS
127125SIMDJSON_DISABLE_DEPRECATED_WARNING
128126static void iterator_twitter_default_profile (State& state) {
129127 // Count unique users with a default profile.
130- padded_string json = padded_string::load (JSON_TEST_PATH );
128+ padded_string json = padded_string::load (TWITTER_JSON );
131129 ParsedJson pj = build_parsed_json (json);
132130 for (auto _ : state) {
133131 set<string_view> default_users;
@@ -167,7 +165,7 @@ BENCHMARK(iterator_twitter_default_profile);
167165static void error_code_twitter_image_sizes (State& state) noexcept {
168166 // Count unique image sizes
169167 dom::parser parser;
170- dom::element doc = parser.load (JSON_TEST_PATH );
168+ dom::element doc = parser.load (TWITTER_JSON );
171169 for (auto _ : state) {
172170 set<tuple<uint64_t , uint64_t >> image_sizes;
173171 auto [statuses, error] = doc[" statuses" ].get <dom::array>();
@@ -196,7 +194,7 @@ SIMDJSON_PUSH_DISABLE_WARNINGS
196194SIMDJSON_DISABLE_DEPRECATED_WARNING
197195static void iterator_twitter_image_sizes (State& state) {
198196 // Count unique image sizes
199- padded_string json = padded_string::load (JSON_TEST_PATH );
197+ padded_string json = padded_string::load (TWITTER_JSON );
200198 ParsedJson pj = build_parsed_json (json);
201199 for (auto _ : state) {
202200 set<tuple<uint64_t , uint64_t >> image_sizes;
@@ -254,7 +252,7 @@ BENCHMARK(iterator_twitter_image_sizes);
254252
255253static void print_json (State& state) noexcept {
256254 // Prints the number of results in twitter.json
257- padded_string json = get_corpus (JSON_TEST_PATH );
255+ padded_string json = get_corpus (TWITTER_JSON );
258256 dom::parser parser;
259257 if (int error = json_parse (json, parser); error != SUCCESS ) { cerr << error_message (error) << endl; return ; }
260258 for (auto _ : state) {
0 commit comments