From 1d9926698ec5c4008b05938079eb1938dcc2c9a9 Mon Sep 17 00:00:00 2001 From: Paul Dreik Date: Sat, 10 Oct 2020 00:22:37 +0200 Subject: [PATCH] update how boost.json is invoked, fix missing separators (#1203) * initial try at adding boost json to the benchmark * clean up * qualify memcpy etc. with std:: * clang format * extra space * update benchmark with help from Vinnie Falco from Boost.json * add missing separators --- benchmark/benchmark.h | 2 ++ benchmark/parsingcompetition.cpp | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/benchmark/benchmark.h b/benchmark/benchmark.h index 7e043aa5..cdcf7331 100644 --- a/benchmark/benchmark.h +++ b/benchmark/benchmark.h @@ -50,6 +50,7 @@ if (verbose) { \ std::printf(" GB/s "); \ } \ + std::printf("\t"); \ std::printf("%7.3f", 1.0 / aggregate.best.elapsed_sec()); \ if (verbose) { \ std::printf(" documents/s "); \ @@ -96,6 +97,7 @@ if (verbose) { \ std::printf(" GB/s "); \ } \ + std::printf("\t"); \ std::printf("%7.3f", 1.0 / aggregate.best.elapsed_sec()); \ if (verbose) { \ std::printf(" documents/s "); \ diff --git a/benchmark/parsingcompetition.cpp b/benchmark/parsingcompetition.cpp index 674534cd..7e316fc8 100644 --- a/benchmark/parsingcompetition.cpp +++ b/benchmark/parsingcompetition.cpp @@ -26,7 +26,8 @@ SIMDJSON_PUSH_DISABLE_ALL_WARNINGS #include using json = nlohmann::json; -#include +#include +#include #ifdef ALLPARSER @@ -176,10 +177,15 @@ bool bench(const char *filename, bool verbose, bool just_data, { const boost::json::string_view sv(p.data(), p.size()); - auto execute = [](auto sv) -> bool { + boost::json::parser p; + auto execute = [&p](auto sv) -> bool { boost::json::error_code ec; - auto jv = boost::json::parse(sv, ec); - return !!ec; + boost::json::monotonic_resource mr; + p.reset( &mr ); + p.write(sv,ec); + if(!ec) + auto jv=p.release(); + return !!ec; }; BEST_TIME("Boost.json", execute(sv), false, , repeat, volume, !just_data);