summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--benchmark/fixtures/api/cache.dbbin1298432 -> 1298432 bytes
-rw-r--r--benchmark/util/dtoa.benchmark.cpp66
-rw-r--r--cmake/benchmark-files.cmake3
3 files changed, 69 insertions, 0 deletions
diff --git a/benchmark/fixtures/api/cache.db b/benchmark/fixtures/api/cache.db
index c2ada1fbd5..6a1d60421f 100644
--- a/benchmark/fixtures/api/cache.db
+++ b/benchmark/fixtures/api/cache.db
Binary files differ
diff --git a/benchmark/util/dtoa.benchmark.cpp b/benchmark/util/dtoa.benchmark.cpp
new file mode 100644
index 0000000000..0009c6dd15
--- /dev/null
+++ b/benchmark/util/dtoa.benchmark.cpp
@@ -0,0 +1,66 @@
+#include <benchmark/benchmark.h>
+
+#include <mbgl/util/dtoa.hpp>
+
+#include <cfloat>
+#include <cmath>
+
+using namespace mbgl;
+
+static void Util_dtoa(::benchmark::State& state) {
+ while (state.KeepRunning()) {
+ util::dtoa(0.);
+ util::dtoa(M_E);
+ util::dtoa(M_LOG2E);
+ util::dtoa(M_LOG10E);
+ util::dtoa(M_LN2);
+ util::dtoa(M_LN10);
+ util::dtoa(M_PI);
+ util::dtoa(M_PI_2);
+ util::dtoa(M_PI_4);
+ util::dtoa(M_1_PI);
+ util::dtoa(M_2_PI);
+ util::dtoa(M_2_SQRTPI);
+ util::dtoa(M_SQRT2);
+ util::dtoa(M_SQRT1_2);
+ }
+}
+
+static void Util_standardDtoa(::benchmark::State& state) {
+ while (state.KeepRunning()) {
+ std::to_string(0.);
+ std::to_string(M_E);
+ std::to_string(M_LOG2E);
+ std::to_string(M_LOG10E);
+ std::to_string(M_LN2);
+ std::to_string(M_LN10);
+ std::to_string(M_PI);
+ std::to_string(M_PI_2);
+ std::to_string(M_PI_4);
+ std::to_string(M_1_PI);
+ std::to_string(M_2_PI);
+ std::to_string(M_2_SQRTPI);
+ std::to_string(M_SQRT2);
+ std::to_string(M_SQRT1_2);
+ }
+}
+
+static void Util_dtoaLimits(::benchmark::State& state) {
+ while (state.KeepRunning()) {
+ util::dtoa(DBL_MIN);
+ util::dtoa(DBL_MAX);
+ }
+}
+
+static void Util_standardDtoaLimits(::benchmark::State& state) {
+ while (state.KeepRunning()) {
+ std::to_string(DBL_MIN);
+ std::to_string(DBL_MAX);
+ }
+}
+
+BENCHMARK(Util_dtoa);
+BENCHMARK(Util_standardDtoa);
+
+BENCHMARK(Util_dtoaLimits);
+BENCHMARK(Util_standardDtoaLimits);
diff --git a/cmake/benchmark-files.cmake b/cmake/benchmark-files.cmake
index 35931a6b52..6fb9a80d57 100644
--- a/cmake/benchmark-files.cmake
+++ b/cmake/benchmark-files.cmake
@@ -19,4 +19,7 @@ set(MBGL_BENCHMARK_FILES
benchmark/src/mbgl/benchmark/benchmark.cpp
benchmark/src/mbgl/benchmark/util.cpp
benchmark/src/mbgl/benchmark/util.hpp
+
+ # util
+ benchmark/util/dtoa.benchmark.cpp
)