summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2018-12-20 10:22:00 +0200
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-01-11 09:49:36 +0200
commit2da9d483ac8bce5bfa7523f9113e1bc4ef2cbfb5 (patch)
treeafe1d90ec2179547f10452a8840b2dbadce91538 /platform
parent6a31c9987bc8b8f67c20dea8d437d72d109d6be1 (diff)
downloadqtlocation-mapboxgl-2da9d483ac8bce5bfa7523f9113e1bc4ef2cbfb5.tar.gz
[android] Implement google benchmark runner for Android platform
Diffstat (limited to 'platform')
-rw-r--r--platform/android/MapboxGLAndroidSDK/build.gradle4
-rw-r--r--platform/android/config.cmake20
-rw-r--r--platform/android/src/test/benchmark_runner.cpp10
-rw-r--r--platform/default/src/mbgl/benchmark/main.cpp5
-rw-r--r--platform/linux/config.cmake4
-rw-r--r--platform/macos/config.cmake4
6 files changed, 43 insertions, 4 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle
index 2c97965866..e8f4539210 100644
--- a/platform/android/MapboxGLAndroidSDK/build.gradle
+++ b/platform/android/MapboxGLAndroidSDK/build.gradle
@@ -96,6 +96,10 @@ android {
targets "mbgl-test"
}
+ if (project.hasProperty("mapbox.with_benchmark")) {
+ targets "mbgl-benchmark"
+ }
+
if (abi != 'all') {
abiFilters abi.split(' ')
} else {
diff --git a/platform/android/config.cmake b/platform/android/config.cmake
index d78a6ce94b..d0d2c42eb6 100644
--- a/platform/android/config.cmake
+++ b/platform/android/config.cmake
@@ -108,6 +108,26 @@ macro(mbgl_platform_test)
)
endmacro()
+## Benchmark ##
+macro(mbgl_platform_benchmark)
+ target_sources(mbgl-benchmark
+ PRIVATE platform/android/src/test/benchmark_runner.cpp
+ PRIVATE platform/android/src/test/runtime.cpp
+ )
+
+ set_target_properties(mbgl-benchmark
+ PROPERTIES
+ LINK_FLAGS
+ "-fPIE -pie \
+ -Wl,--export-dynamic \
+ -Wl,--version-script=${CMAKE_SOURCE_DIR}/platform/android/src/test/version-script")
+
+ target_link_libraries(mbgl-benchmark
+ PRIVATE mbgl-filesource
+ )
+endmacro()
+
+
## Custom layer example ##
add_library(example-custom-layer SHARED
diff --git a/platform/android/src/test/benchmark_runner.cpp b/platform/android/src/test/benchmark_runner.cpp
new file mode 100644
index 0000000000..321a37a028
--- /dev/null
+++ b/platform/android/src/test/benchmark_runner.cpp
@@ -0,0 +1,10 @@
+#include "runtime.hpp"
+#include <mbgl/benchmark.hpp>
+
+int main(int argc, char *argv[]) {
+ if (!mbgl::android::initRuntime(argc, argv)) {
+ return 1;
+ }
+
+ return mbgl::runBenchmark(argc, argv);
+}
diff --git a/platform/default/src/mbgl/benchmark/main.cpp b/platform/default/src/mbgl/benchmark/main.cpp
new file mode 100644
index 0000000000..afe785140f
--- /dev/null
+++ b/platform/default/src/mbgl/benchmark/main.cpp
@@ -0,0 +1,5 @@
+#include <mbgl/benchmark.hpp>
+
+int main(int argc, char* argv[]) {
+ return mbgl::runBenchmark(argc, argv);
+}
diff --git a/platform/linux/config.cmake b/platform/linux/config.cmake
index bcd60cac9e..1df501a84e 100644
--- a/platform/linux/config.cmake
+++ b/platform/linux/config.cmake
@@ -173,11 +173,11 @@ endmacro()
macro(mbgl_platform_benchmark)
target_sources(mbgl-benchmark
- PRIVATE benchmark/src/main.cpp
+ PRIVATE platform/default/src/mbgl/benchmark/main.cpp
)
set_source_files_properties(
- benchmark/src/main.cpp
+ platform/default/src/mbgl/benchmark/main.cpp
PROPERTIES
COMPILE_FLAGS -DWORK_DIRECTORY="${CMAKE_SOURCE_DIR}"
)
diff --git a/platform/macos/config.cmake b/platform/macos/config.cmake
index bc3de392dd..0e1e6be412 100644
--- a/platform/macos/config.cmake
+++ b/platform/macos/config.cmake
@@ -102,11 +102,11 @@ endmacro()
macro(mbgl_platform_benchmark)
target_sources(mbgl-benchmark
PRIVATE platform/default/src/mbgl/layermanager/layer_manager.cpp
- PRIVATE benchmark/src/main.cpp
+ PRIVATE platform/default/src/mbgl/benchmark/main.cpp
)
set_source_files_properties(
- benchmark/src/main.cpp
+ platform/default/src/mbgl/benchmark/main.cpp
PROPERTIES
COMPILE_FLAGS -DWORK_DIRECTORY="${CMAKE_SOURCE_DIR}"
)