diff --git a/implementations/jsontoolkit/CMakeLists.txt b/implementations/jsontoolkit/CMakeLists.txt index 6e4bca9..ccd7c75 100644 --- a/implementations/jsontoolkit/CMakeLists.txt +++ b/implementations/jsontoolkit/CMakeLists.txt @@ -6,4 +6,5 @@ add_subdirectory(../../dist/temp/jsontoolkit/repo jsontoolkit) add_executable(jsontoolkit_benchmark main.cc) noa_add_default_options(PRIVATE jsontoolkit_benchmark) target_link_libraries(jsontoolkit_benchmark PRIVATE sourcemeta::jsontoolkit::json) +target_link_libraries(jsontoolkit_benchmark PRIVATE sourcemeta::jsontoolkit::jsonl) target_link_libraries(jsontoolkit_benchmark PRIVATE sourcemeta::jsontoolkit::jsonschema) diff --git a/implementations/jsontoolkit/main.cc b/implementations/jsontoolkit/main.cc index d6f4158..2c0fab2 100644 --- a/implementations/jsontoolkit/main.cc +++ b/implementations/jsontoolkit/main.cc @@ -1,9 +1,11 @@ #include +#include #include #include #include #include +#include int main(int argc, char **argv) { if (argc < 2) { @@ -13,7 +15,11 @@ int main(int argc, char **argv) { const std::filesystem::path example{argv[1]}; const auto schema{sourcemeta::jsontoolkit::from_file(example / "schema.json")}; - const auto instance{sourcemeta::jsontoolkit::from_file(example / "instances.jsonl")}; + auto stream{sourcemeta::jsontoolkit::read_file(example / "instances.jsonl")}; + std::vector instances; + for (const auto &instance : sourcemeta::jsontoolkit::JSONL{stream}) { + instances.push_back(instance); + } const auto schema_template{sourcemeta::jsontoolkit::compile( schema, sourcemeta::jsontoolkit::default_schema_walker, @@ -21,13 +27,17 @@ int main(int argc, char **argv) { sourcemeta::jsontoolkit::default_schema_compiler)}; const auto timestamp_start{std::chrono::high_resolution_clock::now()}; - const auto result{sourcemeta::jsontoolkit::evaluate( - schema_template, instance)}; - const auto timestamp_end{std::chrono::high_resolution_clock::now()}; - if (!result) { - return EXIT_FAILURE; + + for (const auto &instance : instances) { + const auto result{sourcemeta::jsontoolkit::evaluate( + schema_template, instance)}; + if (!result) { + return EXIT_FAILURE; + } } + const auto timestamp_end{std::chrono::high_resolution_clock::now()}; + const auto duration{ std::chrono::duration_cast(timestamp_end - timestamp_start)}; std::cout << duration.count() << "\n";