diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-10-16 15:40:07 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-10-16 17:14:19 -0700 |
commit | 12f78fc8747332a3d54763c9b0cc2e794eefb4f8 (patch) | |
tree | fb10590f6605226a16dc528965ba541ff9371ec4 /benchmark | |
parent | b8654b3b04599988f1f7a519853e98d4ca54cfd0 (diff) | |
download | qtlocation-mapboxgl-12f78fc8747332a3d54763c9b0cc2e794eefb4f8.tar.gz |
[core] Use convertJSON instead of RapidJSON directly
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/function/camera_function.benchmark.cpp | 18 | ||||
-rw-r--r-- | benchmark/function/composite_function.benchmark.cpp | 17 | ||||
-rw-r--r-- | benchmark/function/source_function.benchmark.cpp | 17 | ||||
-rw-r--r-- | benchmark/parse/filter.benchmark.cpp | 8 |
4 files changed, 17 insertions, 43 deletions
diff --git a/benchmark/function/camera_function.benchmark.cpp b/benchmark/function/camera_function.benchmark.cpp index 1f8fe4579f..26de5701db 100644 --- a/benchmark/function/camera_function.benchmark.cpp +++ b/benchmark/function/camera_function.benchmark.cpp @@ -1,20 +1,14 @@ #include <benchmark/benchmark.h> #include <mbgl/style/function/source_function.hpp> - -#include <mbgl/style/rapidjson_conversion.hpp> #include <mbgl/style/conversion.hpp> +#include <mbgl/style/conversion/json.hpp> #include <mbgl/style/conversion/function.hpp> -#include <rapidjson/document.h> - - using namespace mbgl; using namespace mbgl::style; -static rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> createFunctionJSON(size_t stopCount) { - rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> doc; - +static std::string createFunctionJSON(size_t stopCount) { std::string stops = "["; for (size_t i = 0; i < stopCount; i++) { std::string value = std::to_string(24.0f / stopCount * i); @@ -22,9 +16,7 @@ static rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> cr stops += "[" + value + ", " + value + "]"; } stops += "]"; - - doc.Parse<0>(R"({"type": "exponential", "base": 2, "stops": )" + stops + "}"); - return doc; + return R"({"type": "exponential", "base": 2, "stops": )" + stops + "}"; } static void Parse_CameraFunction(benchmark::State& state) { @@ -35,7 +27,7 @@ static void Parse_CameraFunction(benchmark::State& state) { state.PauseTiming(); auto doc = createFunctionJSON(stopCount); state.ResumeTiming(); - optional<CameraFunction<float>> result = conversion::convert<CameraFunction<float>, JSValue>(doc, error); + optional<CameraFunction<float>> result = conversion::convertJSON<CameraFunction<float>>(doc, error); if (!result) { state.SkipWithError(error.message.c_str()); } @@ -47,7 +39,7 @@ static void Evaluate_CameraFunction(benchmark::State& state) { size_t stopCount = state.range(0); auto doc = createFunctionJSON(stopCount); conversion::Error error; - optional<CameraFunction<float>> function = conversion::convert<CameraFunction<float>, JSValue>(doc, error); + optional<CameraFunction<float>> function = conversion::convertJSON<CameraFunction<float>>(doc, error); if (!function) { state.SkipWithError(error.message.c_str()); } 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 <mbgl/style/function/composite_exponential_stops.hpp> #include <mbgl/style/function/composite_function.hpp> -#include <mbgl/style/rapidjson_conversion.hpp> #include <mbgl/style/conversion.hpp> +#include <mbgl/style/conversion/json.hpp> #include <mbgl/style/conversion/function.hpp> -#include <rapidjson/document.h> - - using namespace mbgl; using namespace mbgl::style; -static rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> createFunctionJSON(size_t stopCount) { - rapidjson::GenericDocument<rapidjson::UTF8<>, 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::UTF8<>, 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<CompositeFunction<float>> result = conversion::convert<style::CompositeFunction<float>, JSValue>(doc, error); + optional<CompositeFunction<float>> result = conversion::convertJSON<style::CompositeFunction<float>>(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<CompositeFunction<float>> function = conversion::convert<CompositeFunction<float>, JSValue>(doc, error); + optional<CompositeFunction<float>> function = conversion::convertJSON<CompositeFunction<float>>(doc, error); if (!function) { state.SkipWithError(error.message.c_str()); } diff --git a/benchmark/function/source_function.benchmark.cpp b/benchmark/function/source_function.benchmark.cpp index 14e729eee2..af361943e3 100644 --- a/benchmark/function/source_function.benchmark.cpp +++ b/benchmark/function/source_function.benchmark.cpp @@ -4,19 +4,14 @@ #include <mbgl/style/function/source_function.hpp> -#include <mbgl/style/rapidjson_conversion.hpp> #include <mbgl/style/conversion.hpp> +#include <mbgl/style/conversion/json.hpp> #include <mbgl/style/conversion/function.hpp> -#include <rapidjson/document.h> - - using namespace mbgl; using namespace mbgl::style; -static rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> createFunctionJSON(size_t stopCount) { - rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> doc; - +static std::string createFunctionJSON(size_t stopCount) { std::string stops = "["; for (size_t i = 0; i < stopCount; i++) { std::string value = std::to_string(100.0f / stopCount * i); @@ -24,9 +19,7 @@ static rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> cr stops += "[" + value + ", " + value + "]"; } 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_SourceFunction(benchmark::State& state) { @@ -37,7 +30,7 @@ static void Parse_SourceFunction(benchmark::State& state) { state.PauseTiming(); auto doc = createFunctionJSON(stopCount); state.ResumeTiming(); - optional<SourceFunction<float>> result = conversion::convert<SourceFunction<float>, JSValue>(doc, error); + optional<SourceFunction<float>> result = conversion::convertJSON<SourceFunction<float>>(doc, error); if (!result) { state.SkipWithError(error.message.c_str()); } @@ -49,7 +42,7 @@ static void Evaluate_SourceFunction(benchmark::State& state) { size_t stopCount = state.range(0); auto doc = createFunctionJSON(stopCount); conversion::Error error; - optional<SourceFunction<float>> function = conversion::convert<SourceFunction<float>, JSValue>(doc, error); + optional<SourceFunction<float>> function = conversion::convertJSON<SourceFunction<float>>(doc, error); if (!function) { state.SkipWithError(error.message.c_str()); } diff --git a/benchmark/parse/filter.benchmark.cpp b/benchmark/parse/filter.benchmark.cpp index d650cb72c9..4984668400 100644 --- a/benchmark/parse/filter.benchmark.cpp +++ b/benchmark/parse/filter.benchmark.cpp @@ -2,20 +2,16 @@ #include <mbgl/style/filter.hpp> #include <mbgl/style/filter_evaluator.hpp> -#include <mbgl/style/rapidjson_conversion.hpp> #include <mbgl/style/conversion.hpp> +#include <mbgl/style/conversion/json.hpp> #include <mbgl/style/conversion/filter.hpp> #include <mbgl/tile/geometry_tile_data.hpp> -#include <rapidjson/document.h> - using namespace mbgl; style::Filter parse(const char* expression) { - rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> doc; - doc.Parse<0>(expression); style::conversion::Error error; - return *style::conversion::convert<style::Filter, JSValue>(doc, error); + return *style::conversion::convertJSON<style::Filter>(expression, error); } static void Parse_Filter(benchmark::State& state) { |