@@ -473,28 +473,6 @@ static void twitter_count(State& state) {
473
473
}
474
474
BENCHMARK (twitter_count);
475
475
476
- #ifndef SIMDJSON_DISABLE_DEPRECATED_API
477
- SIMDJSON_PUSH_DISABLE_WARNINGS
478
- SIMDJSON_DISABLE_DEPRECATED_WARNING
479
- static void iterator_twitter_count (State& state) {
480
- // Prints the number of results in twitter.json
481
- padded_string json = padded_string::load (TWITTER_JSON);
482
- ParsedJson pj = build_parsed_json (json);
483
- for (simdjson_unused auto _ : state) {
484
- ParsedJson::Iterator iter (pj);
485
- // uint64_t result_count = doc["search_metadata"]["count"];
486
- if (!iter.move_to_key (" search_metadata" )) { return ; }
487
- if (!iter.move_to_key (" count" )) { return ; }
488
- if (!iter.is_integer ()) { return ; }
489
- int64_t result_count = iter.get_integer ();
490
-
491
- if (result_count != 100 ) { return ; }
492
- }
493
- }
494
- BENCHMARK (iterator_twitter_count);
495
- SIMDJSON_POP_DISABLE_WARNINGS
496
- #endif // SIMDJSON_DISABLE_DEPRECATED_API
497
-
498
476
static void twitter_default_profile (State& state) {
499
477
// Count unique users with a default profile.
500
478
dom::parser parser;
@@ -578,54 +556,6 @@ static void error_code_twitter_default_profile(State& state) noexcept {
578
556
}
579
557
BENCHMARK (error_code_twitter_default_profile);
580
558
581
- #ifndef SIMDJSON_DISABLE_DEPRECATED_API
582
-
583
- SIMDJSON_PUSH_DISABLE_WARNINGS
584
- SIMDJSON_DISABLE_DEPRECATED_WARNING
585
-
586
- static void iterator_twitter_default_profile (State& state) {
587
- // Count unique users with a default profile.
588
- padded_string json;
589
- auto error = padded_string::load (TWITTER_JSON).get (json);
590
- if (error) { std::cerr << error << std::endl; return ; }
591
- ParsedJson pj = build_parsed_json (json);
592
- for (simdjson_unused auto _ : state) {
593
- set<string_view> default_users;
594
- ParsedJson::Iterator iter (pj);
595
-
596
- // for (dom::object tweet : doc["statuses"]) {
597
- if (!(iter.move_to_key (" statuses" ) && iter.is_array ())) { return ; }
598
- if (iter.down ()) { // first status
599
- do {
600
-
601
- // dom::object user = tweet["user"];
602
- if (!(iter.move_to_key (" user" ) && iter.is_object ())) { return ; }
603
-
604
- // if (user["default_profile"]) {
605
- if (iter.move_to_key (" default_profile" )) {
606
- if (iter.is_true ()) {
607
- if (!iter.up ()) { return ; } // back to user
608
-
609
- // default_users.insert(user["screen_name"]);
610
- if (!(iter.move_to_key (" screen_name" ) && iter.is_string ())) { return ; }
611
- default_users.emplace (iter.get_string (), iter.get_string_length ());
612
- }
613
- if (!iter.up ()) { return ; } // back to user
614
- }
615
-
616
- if (!iter.up ()) { return ; } // back to status
617
-
618
- } while (iter.next ()); // next status
619
- }
620
-
621
- if (default_users.size () != 86 ) { return ; }
622
- }
623
- }
624
-
625
- SIMDJSON_POP_DISABLE_WARNINGS
626
- BENCHMARK (iterator_twitter_default_profile);
627
- #endif // SIMDJSON_DISABLE_DEPRECATED_API
628
-
629
559
static void error_code_twitter_image_sizes (State& state) noexcept {
630
560
// Count unique image sizes
631
561
dom::parser parser;
@@ -680,92 +610,4 @@ static void parse_surrogate_pairs(State& state) {
680
610
}
681
611
BENCHMARK (parse_surrogate_pairs);
682
612
683
-
684
- #ifndef SIMDJSON_DISABLE_DEPRECATED_API
685
-
686
- SIMDJSON_PUSH_DISABLE_WARNINGS
687
- SIMDJSON_DISABLE_DEPRECATED_WARNING
688
- static void iterator_twitter_image_sizes (State& state) {
689
- // Count unique image sizes
690
- padded_string json;
691
- auto error = padded_string::load (TWITTER_JSON).get (json);
692
- if (error) { std::cerr << error << std::endl; return ; }
693
- ParsedJson pj = build_parsed_json (json);
694
- for (simdjson_unused auto _ : state) {
695
- set<tuple<uint64_t , uint64_t >> image_sizes;
696
- ParsedJson::Iterator iter (pj);
697
-
698
- // for (dom::object tweet : doc["statuses"]) {
699
- if (!(iter.move_to_key (" statuses" ) && iter.is_array ())) { return ; }
700
- if (iter.down ()) { // first status
701
- do {
702
-
703
- // dom::object media;
704
- // not_found = tweet["entities"]["media"].get(media);
705
- // if (!not_found) {
706
- if (iter.move_to_key (" entities" )) {
707
- if (!iter.is_object ()) { return ; }
708
- if (iter.move_to_key (" media" )) {
709
- if (!iter.is_array ()) { return ; }
710
-
711
- // for (dom::object image : media) {
712
- if (iter.down ()) { // first media
713
- do {
714
-
715
- // for (auto [key, size] : dom::object(image["sizes"])) {
716
- if (!(iter.move_to_key (" sizes" ) && iter.is_object ())) { return ; }
717
- if (iter.down ()) { // first size
718
- do {
719
- iter.move_to_value ();
720
-
721
- // image_sizes.insert({ size["w"], size["h"] });
722
- if (!(iter.move_to_key (" w" )) && !iter.is_integer ()) { return ; }
723
- uint64_t width = iter.get_integer ();
724
- if (!iter.up ()) { return ; } // back to size
725
- if (!(iter.move_to_key (" h" )) && !iter.is_integer ()) { return ; }
726
- uint64_t height = iter.get_integer ();
727
- if (!iter.up ()) { return ; } // back to size
728
- image_sizes.emplace (width, height);
729
-
730
- } while (iter.next ()); // next size
731
- if (!iter.up ()) { return ; } // back to sizes
732
- }
733
- if (!iter.up ()) { return ; } // back to image
734
- } while (iter.next ()); // next image
735
- if (!iter.up ()) { return ; } // back to media
736
- }
737
- if (!iter.up ()) { return ; } // back to entities
738
- }
739
- if (!iter.up ()) { return ; } // back to status
740
- }
741
- } while (iter.next ()); // next status
742
- }
743
-
744
- if (image_sizes.size () != 15 ) { return ; };
745
- }
746
- }
747
- BENCHMARK (iterator_twitter_image_sizes);
748
-
749
- #endif // SIMDJSON_DISABLE_DEPRECATED_API
750
-
751
- #ifndef SIMDJSON_DISABLE_DEPRECATED_API
752
- static void print_json (State& state) noexcept {
753
- // Prints the number of results in twitter.json
754
- dom::parser parser;
755
-
756
- padded_string json;
757
- auto error = padded_string::load (TWITTER_JSON).get (json);
758
- if (error) { std::cerr << error << std::endl; return ; }
759
-
760
- int code = json_parse (json, parser);
761
- if (code) { cerr << error_message (code) << endl; return ; }
762
- for (simdjson_unused auto _ : state) {
763
- std::stringstream s;
764
- if (!parser.print_json (s)) { cerr << " print_json failed" << endl; return ; }
765
- }
766
- }
767
- BENCHMARK (print_json);
768
- #endif // SIMDJSON_DISABLE_DEPRECATED_API
769
- SIMDJSON_POP_DISABLE_WARNINGS
770
-
771
613
BENCHMARK_MAIN ();
0 commit comments