From 377a0ab9fc804bc4a6f5fe0e783a42bc17114854 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 16 Oct 2017 15:40:07 -0700 Subject: [core] Use convertJSON instead of RapidJSON directly --- benchmark/function/composite_function.benchmark.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'benchmark/function/composite_function.benchmark.cpp') diff --git a/benchmark/function/composite_function.benchmark.cpp b/benchmark/function/composite_function.benchmark.cpp index f04b6c7073..e2545e6349 100644 --- a/benchmark/function/composite_function.benchmark.cpp +++ b/benchmark/function/composite_function.benchmark.cpp @@ -5,19 +5,14 @@ #include #include -#include #include +#include #include -#include - - using namespace mbgl; using namespace mbgl::style; -static rapidjson::GenericDocument, rapidjson::CrtAllocator> createFunctionJSON(size_t stopCount) { - rapidjson::GenericDocument, rapidjson::CrtAllocator> doc; - +static std::string createFunctionJSON(size_t stopCount) { std::string stops = "["; for (size_t outerStop = 0; outerStop < stopCount; outerStop++) { for (size_t innerStop = 0; innerStop < stopCount; innerStop++) { @@ -29,9 +24,7 @@ static rapidjson::GenericDocument, rapidjson::CrtAllocator> cr } } stops += "]"; - - doc.Parse<0>(R"({"type": "exponential", "base": 2, "stops": )" + stops + R"(, "property": "x"})"); - return doc; + return R"({"type": "exponential", "base": 2, "stops": )" + stops + R"(, "property": "x"})"; } static void Parse_CompositeFunction(benchmark::State& state) { @@ -42,7 +35,7 @@ static void Parse_CompositeFunction(benchmark::State& state) { state.PauseTiming(); auto doc = createFunctionJSON(stopCount); state.ResumeTiming(); - optional> result = conversion::convert, JSValue>(doc, error); + optional> result = conversion::convertJSON>(doc, error); if (!result) { state.SkipWithError(error.message.c_str()); } @@ -54,7 +47,7 @@ static void Evaluate_CompositeFunction(benchmark::State& state) { size_t stopCount = state.range(0); auto doc = createFunctionJSON(stopCount); conversion::Error error; - optional> function = conversion::convert, JSValue>(doc, error); + optional> function = conversion::convertJSON>(doc, error); if (!function) { state.SkipWithError(error.message.c_str()); } -- cgit v1.2.1