@@ -21,13 +21,14 @@ static std::string createFunctionJSON(size_t stopCount) {
|
||||
|
||||
static void Parse_CameraFunction(benchmark::State& state) {
|
||||
size_t stopCount = state.range(0);
|
||||
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
conversion::Error error;
|
||||
state.PauseTiming();
|
||||
auto doc = createFunctionJSON(stopCount);
|
||||
state.ResumeTiming();
|
||||
std::optional<PropertyValue<float>> result = conversion::convertJSON<PropertyValue<float>>(doc, error, false, false);
|
||||
std::optional<PropertyValue<float>> result = conversion::convertJSON<PropertyValue<float>>(
|
||||
doc, error, false, false);
|
||||
if (!result) {
|
||||
state.SkipWithError(error.message.c_str());
|
||||
}
|
||||
@@ -39,23 +40,20 @@ static void Evaluate_CameraFunction(benchmark::State& state) {
|
||||
size_t stopCount = state.range(0);
|
||||
auto doc = createFunctionJSON(stopCount);
|
||||
conversion::Error error;
|
||||
std::optional<PropertyValue<float>> function = conversion::convertJSON<PropertyValue<float>>(doc, error, false, false);
|
||||
std::optional<PropertyValue<float>> function = conversion::convertJSON<PropertyValue<float>>(
|
||||
doc, error, false, false);
|
||||
if (!function) {
|
||||
state.SkipWithError(error.message.c_str());
|
||||
}
|
||||
|
||||
while(state.KeepRunning()) {
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
float z = 24.0f * static_cast<float>(rand() % 100) / 100;
|
||||
function->asExpression().evaluate(z);
|
||||
}
|
||||
|
||||
|
||||
state.SetLabel(std::to_string(stopCount).c_str());
|
||||
}
|
||||
|
||||
BENCHMARK(Parse_CameraFunction)
|
||||
->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
BENCHMARK(Evaluate_CameraFunction)
|
||||
->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
BENCHMARK(Parse_CameraFunction)->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
BENCHMARK(Evaluate_CameraFunction)->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
@@ -18,7 +18,7 @@ static std::string createFunctionJSON(size_t stopCount) {
|
||||
std::string value = std::to_string(100.0f / stopCount * innerStop);
|
||||
|
||||
if (stops.size() > 1) stops += ",";
|
||||
stops += R"([{"zoom":)" + zoom + R"(,"value":)" + value + "}, " + value + "]";
|
||||
stops += R"([{"zoom":)" + zoom + R"(,"value":)" + value + "}, " + value + "]";
|
||||
}
|
||||
}
|
||||
stops += "]";
|
||||
@@ -33,7 +33,8 @@ static void Parse_CompositeFunction(benchmark::State& state) {
|
||||
state.PauseTiming();
|
||||
auto doc = createFunctionJSON(stopCount);
|
||||
state.ResumeTiming();
|
||||
std::optional<PropertyValue<float>> result = conversion::convertJSON<PropertyValue<float>>(doc, error, true, false);
|
||||
std::optional<PropertyValue<float>> result = conversion::convertJSON<PropertyValue<float>>(
|
||||
doc, error, true, false);
|
||||
if (!result) {
|
||||
state.SkipWithError(error.message.c_str());
|
||||
}
|
||||
@@ -45,23 +46,21 @@ static void Evaluate_CompositeFunction(benchmark::State& state) {
|
||||
size_t stopCount = state.range(0);
|
||||
auto doc = createFunctionJSON(stopCount);
|
||||
conversion::Error error;
|
||||
std::optional<PropertyValue<float>> function = conversion::convertJSON<PropertyValue<float>>(doc, error, true, false);
|
||||
std::optional<PropertyValue<float>> function = conversion::convertJSON<PropertyValue<float>>(
|
||||
doc, error, true, false);
|
||||
if (!function) {
|
||||
state.SkipWithError(error.message.c_str());
|
||||
}
|
||||
|
||||
while(state.KeepRunning()) {
|
||||
while (state.KeepRunning()) {
|
||||
float z = 24.0f * static_cast<float>(rand() % 100) / 100;
|
||||
function->asExpression().evaluate(z, StubGeometryTileFeature(PropertyMap { { "x", static_cast<int64_t>(rand() % 100) } }), -1.0f);
|
||||
function->asExpression().evaluate(
|
||||
z, StubGeometryTileFeature(PropertyMap{{"x", static_cast<int64_t>(rand() % 100)}}), -1.0f);
|
||||
}
|
||||
|
||||
state.SetLabel(std::to_string(stopCount).c_str());
|
||||
}
|
||||
|
||||
BENCHMARK(Parse_CompositeFunction)
|
||||
->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
BENCHMARK(Evaluate_CompositeFunction)
|
||||
->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
BENCHMARK(Parse_CompositeFunction)->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
BENCHMARK(Evaluate_CompositeFunction)->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
@@ -28,7 +28,8 @@ static void Parse_SourceFunction(benchmark::State& state) {
|
||||
state.PauseTiming();
|
||||
auto doc = createFunctionJSON(stopCount);
|
||||
state.ResumeTiming();
|
||||
std::optional<PropertyValue<float>> result = conversion::convertJSON<PropertyValue<float>>(doc, error, true, false);
|
||||
std::optional<PropertyValue<float>> result = conversion::convertJSON<PropertyValue<float>>(
|
||||
doc, error, true, false);
|
||||
if (!result) {
|
||||
state.SkipWithError(error.message.c_str());
|
||||
}
|
||||
@@ -40,22 +41,20 @@ static void Evaluate_SourceFunction(benchmark::State& state) {
|
||||
size_t stopCount = state.range(0);
|
||||
auto doc = createFunctionJSON(stopCount);
|
||||
conversion::Error error;
|
||||
std::optional<PropertyValue<float>> function = conversion::convertJSON<PropertyValue<float>>(doc, error, true, false);
|
||||
std::optional<PropertyValue<float>> function = conversion::convertJSON<PropertyValue<float>>(
|
||||
doc, error, true, false);
|
||||
if (!function) {
|
||||
state.SkipWithError(error.message.c_str());
|
||||
}
|
||||
|
||||
while(state.KeepRunning()) {
|
||||
function->asExpression().evaluate(StubGeometryTileFeature(PropertyMap { { "x", static_cast<int64_t>(rand() % 100) } }), -1.0f);
|
||||
while (state.KeepRunning()) {
|
||||
function->asExpression().evaluate(
|
||||
StubGeometryTileFeature(PropertyMap{{"x", static_cast<int64_t>(rand() % 100)}}), -1.0f);
|
||||
}
|
||||
|
||||
state.SetLabel(std::to_string(stopCount).c_str());
|
||||
}
|
||||
|
||||
BENCHMARK(Parse_SourceFunction)
|
||||
->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
BENCHMARK(Evaluate_SourceFunction)
|
||||
->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
BENCHMARK(Parse_SourceFunction)->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
BENCHMARK(Evaluate_SourceFunction)->Arg(1)->Arg(2)->Arg(4)->Arg(6)->Arg(8)->Arg(10)->Arg(12);
|
||||
|
||||
Reference in New Issue
Block a user