@@ -12,6 +12,8 @@ using namespace std;
1212
1313const padded_string EMPTY_ARRAY (" []" , 2 );
1414
15+ #if SIMDJSON_EXCEPTIONS
16+
1517static void twitter_count (State& state) {
1618 // Prints the number of results in twitter.json
1719 document doc = document::load (JSON_TEST_PATH);
@@ -22,17 +24,6 @@ static void twitter_count(State& state) {
2224}
2325BENCHMARK (twitter_count);
2426
25- static void error_code_twitter_count (State& state) noexcept {
26- // Prints the number of results in twitter.json
27- document doc = document::load (JSON_TEST_PATH);
28- for (auto _ : state) {
29- auto [value, error] = doc[" search_metadata" ][" count" ];
30- if (error) { return ; }
31- if (uint64_t (value) != 100 ) { return ; }
32- }
33- }
34- BENCHMARK (error_code_twitter_count);
35-
3627static void iterator_twitter_count (State& state) {
3728 // Prints the number of results in twitter.json
3829 document doc = document::load (JSON_TEST_PATH);
@@ -65,6 +56,39 @@ static void twitter_default_profile(State& state) {
6556}
6657BENCHMARK (twitter_default_profile);
6758
59+ static void twitter_image_sizes (State& state) {
60+ // Count unique image sizes
61+ document doc = document::load (JSON_TEST_PATH);
62+ for (auto _ : state) {
63+ set<tuple<uint64_t , uint64_t >> image_sizes;
64+ for (document::object tweet : doc[" statuses" ].as_array ()) {
65+ auto [media, not_found] = tweet[" entities" ][" media" ];
66+ if (!not_found) {
67+ for (document::object image : media.as_array ()) {
68+ for (auto [key, size] : image[" sizes" ].as_object ()) {
69+ image_sizes.insert ({ size[" w" ], size[" h" ] });
70+ }
71+ }
72+ }
73+ }
74+ if (image_sizes.size () != 15 ) { return ; };
75+ }
76+ }
77+ BENCHMARK (twitter_image_sizes);
78+
79+ #endif // SIMDJSON_EXCEPTIONS
80+
81+ static void error_code_twitter_count (State& state) noexcept {
82+ // Prints the number of results in twitter.json
83+ document doc = document::load (JSON_TEST_PATH);
84+ for (auto _ : state) {
85+ auto [value, error] = doc[" search_metadata" ][" count" ].as_uint64_t ();
86+ if (error) { return ; }
87+ if (value != 100 ) { return ; }
88+ }
89+ }
90+ BENCHMARK (error_code_twitter_count);
91+
6892static void error_code_twitter_default_profile (State& state) noexcept {
6993 // Count unique users with a default profile.
7094 document doc = document::load (JSON_TEST_PATH);
@@ -127,26 +151,6 @@ static void iterator_twitter_default_profile(State& state) {
127151}
128152BENCHMARK (iterator_twitter_default_profile);
129153
130- static void twitter_image_sizes (State& state) {
131- // Count unique image sizes
132- document doc = document::load (JSON_TEST_PATH);
133- for (auto _ : state) {
134- set<tuple<uint64_t , uint64_t >> image_sizes;
135- for (document::object tweet : doc[" statuses" ].as_array ()) {
136- auto [media, not_found] = tweet[" entities" ][" media" ];
137- if (!not_found) {
138- for (document::object image : media.as_array ()) {
139- for (auto [key, size] : image[" sizes" ].as_object ()) {
140- image_sizes.insert ({ size[" w" ], size[" h" ] });
141- }
142- }
143- }
144- }
145- if (image_sizes.size () != 15 ) { return ; };
146- }
147- }
148- BENCHMARK (twitter_image_sizes);
149-
150154static void error_code_twitter_image_sizes (State& state) noexcept {
151155 // Count unique image sizes
152156 document doc = document::load (JSON_TEST_PATH);
0 commit comments