From 55acc15a774ff4425e5ddbc68485adbef80d48bc Mon Sep 17 00:00:00 2001 From: Courier Ma Date: Mon, 12 Dec 2022 23:37:34 +0800 Subject: [PATCH] update benchmark --- benchmark/benchmark.cpp | 50 ++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/benchmark/benchmark.cpp b/benchmark/benchmark.cpp index f6fcbe71..b8ec0fc2 100644 --- a/benchmark/benchmark.cpp +++ b/benchmark/benchmark.cpp @@ -269,40 +269,48 @@ void test_to_json() { #endif } -void test_parse() { - using variant = - std::variant, instruments_t>; - - std::map test_map{ - {"../data/canada.json", FeatureCollection{}}, - {"../data/apache_builds.json", apache_builds{}}, - {"../data/citm_catalog.json", citm_object_t{}}, - {"../data/gsoc-2018.json", gsoc_object_t{}}, - {"../data/mesh.pretty.json", mesh_t{}}, - {"../data/random.json", random_t{}}, - {"../data/github_events.json", githubEvents::events_t{}}, - {"../data/marine_ik.json", marine_ik::marine_ik_t{}}, - {"../data/numbers.json", std::vector{}}, - {"../data/instruments.json", instruments_t{}}, - }; +using variant = + std::variant, instruments_t>; + +static std::map test_map{ + {"../data/canada.json", FeatureCollection{}}, + {"../data/apache_builds.json", apache_builds{}}, + {"../data/citm_catalog.json", citm_object_t{}}, + {"../data/gsoc-2018.json", gsoc_object_t{}}, + {"../data/mesh.pretty.json", mesh_t{}}, + {"../data/random.json", random_t{}}, + {"../data/github_events.json", githubEvents::events_t{}}, + {"../data/marine_ik.json", marine_ik::marine_ik_t{}}, + {"../data/numbers.json", std::vector{}}, + {"../data/instruments.json", instruments_t{}}, +}; - iguana::jvalue val; +void test_from_json_file() { for (auto &pair : test_map) { auto content = iguana::json_file_content(pair.first); - std::visit( [&](auto &&arg) { test_from_json(pair.first, arg, content, 10); }, pair.second); + } +} +void test_dom_parse_file() { + for (auto &pair : test_map) { + auto content = iguana::json_file_content(pair.first); test_dom_parse(pair.first, content, 10); } } int main() { for (size_t i = 0; i < 5; i++) { - test_parse(); + test_from_json_file(); + std::cout << "====================\n"; + } + + for (size_t i = 0; i < 5; i++) { + test_dom_parse_file(); std::cout << "====================\n"; }