summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile31
-rw-r--r--benchmark/benchmark-files.json1
-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.cpp (renamed from benchmark/src/main.cpp)0
-rw-r--r--platform/linux/config.cmake4
-rw-r--r--platform/macos/config.cmake4
8 files changed, 69 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 06a57b6419..2ccedf026e 100644
--- a/Makefile
+++ b/Makefile
@@ -498,10 +498,12 @@ MBGL_ANDROID_ABIS += x86;x86
MBGL_ANDROID_ABIS += x86-64;x86_64
MBGL_ANDROID_LOCAL_WORK_DIR = /data/local/tmp/core-tests
+MBGL_ANDROID_LOCAL_BENCHMARK_DIR = /data/local/tmp/benchmark
MBGL_ANDROID_LIBDIR = lib$(if $(filter arm-v8 x86-64,$1),64)
MBGL_ANDROID_DALVIKVM = dalvikvm$(if $(filter arm-v8 x86-64,$1),64,32)
MBGL_ANDROID_APK_SUFFIX = $(if $(filter Release,$(BUILDTYPE)),release,debug)
MBGL_ANDROID_CORE_TEST_DIR = platform/android/MapboxGLAndroidSDK/.externalNativeBuild/cmake/$(buildtype)/$2/core-tests
+MBGL_ANDROID_BENCHMARK_DIR = platform/android/MapboxGLAndroidSDK/.externalNativeBuild/cmake/$(buildtype)/$2/benchmark
MBGL_ANDROID_STL ?= c++_static
MBGL_ANDROID_GRADLE = ./gradlew --parallel --max-workers=$(JOBS) -Pmapbox.buildtype=$(buildtype) -Pmapbox.stl=$(MBGL_ANDROID_STL)
@@ -527,6 +529,10 @@ define ANDROID_RULES
android-test-lib-$1: platform/android/gradle/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=$2 -Pmapbox.with_test=true :MapboxGLAndroidSDKTestApp:assemble$(BUILDTYPE)
+.PHONY: android-benchmark-$1
+android-benchmark-$1: platform/android/gradle/configuration.gradle
+ cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=$2 -Pmapbox.with_benchmark=true :MapboxGLAndroidSDKTestApp:assemble$(BUILDTYPE)
+
# Build SDK for for specified abi
.PHONY: android-lib-$1
android-lib-$1: platform/android/gradle/configuration.gradle
@@ -571,6 +577,31 @@ run-android-core-test-$1-%: android-core-test-$1
.PHONY: run-android-core-test-$1
run-android-core-test-$1: run-android-core-test-$1-*
+# Run benchmarks for specified abi
+.PHONY: run-android-benchmark-$1
+run-android-benchmark-$1: run-android-benchmark-$1-*
+
+run-android-benchmark-$1-%: android-benchmark-$1
+ mkdir -p $(MBGL_ANDROID_BENCHMARK_DIR)
+ unzip -o platform/android/MapboxGLAndroidSDKTestApp/build/outputs/apk/$(buildtype)/MapboxGLAndroidSDKTestApp-$(MBGL_ANDROID_APK_SUFFIX).apk classes.dex -d $(MBGL_ANDROID_BENCHMARK_DIR)
+
+ # Delete old test folder and create new one
+ adb shell "rm -Rf $(MBGL_ANDROID_LOCAL_BENCHMARK_DIR) && mkdir -p $(MBGL_ANDROID_LOCAL_BENCHMARK_DIR)/benchmark && mkdir -p $(MBGL_ANDROID_LOCAL_BENCHMARK_DIR)/test"
+
+ # Push compiled java sources, test data and executable to device
+ adb push $(MBGL_ANDROID_BENCHMARK_DIR)/classes.dex $(MBGL_ANDROID_LOCAL_BENCHMARK_DIR) > /dev/null 2>&1
+ adb push platform/android/MapboxGLAndroidSDK/build/intermediates/intermediate-jars/$(buildtype)/jni/$2/libmapbox-gl.so $(MBGL_ANDROID_LOCAL_BENCHMARK_DIR) > /dev/null 2>&1
+ adb push benchmark/fixtures $(MBGL_ANDROID_LOCAL_BENCHMARK_DIR)/benchmark > /dev/null 2>&1
+ adb push test/fixtures $(MBGL_ANDROID_LOCAL_BENCHMARK_DIR)/test > /dev/null 2>&1
+ adb push platform/android/MapboxGLAndroidSDK/build/intermediates/cmake/$(buildtype)/obj/$2/mbgl-benchmark $(MBGL_ANDROID_LOCAL_BENCHMARK_DIR) > /dev/null 2>&1
+
+ # Run benchmark. Number of benchmark iterations can be set by run-android-benchmark-N parameter.
+ adb shell "export LD_LIBRARY_PATH=$(MBGL_ANDROID_LOCAL_BENCHMARK_DIR) && cd $(MBGL_ANDROID_LOCAL_BENCHMARK_DIR) && chmod +x mbgl-benchmark && ./mbgl-benchmark --class_path=$(MBGL_ANDROID_LOCAL_BENCHMARK_DIR)/classes.dex --benchmark_repetitions=$$* --benchmark_format=json --benchmark_out=results.json"
+
+ # Pull results.json from the device
+ rm -rf $(MBGL_ANDROID_BENCHMARK_DIR)/results && mkdir -p $(MBGL_ANDROID_BENCHMARK_DIR)/results
+ adb pull $(MBGL_ANDROID_LOCAL_BENCHMARK_DIR)/results.json $(MBGL_ANDROID_BENCHMARK_DIR)/results > /dev/null 2>&1
+
# Run the test app on connected android device with specified abi
.PHONY: run-android-$1
run-android-$1: platform/android/gradle/configuration.gradle
diff --git a/benchmark/benchmark-files.json b/benchmark/benchmark-files.json
index 6c3ddc6962..e3ad80072b 100644
--- a/benchmark/benchmark-files.json
+++ b/benchmark/benchmark-files.json
@@ -9,7 +9,6 @@
"benchmark/parse/filter.benchmark.cpp",
"benchmark/parse/tile_mask.benchmark.cpp",
"benchmark/parse/vector_tile.benchmark.cpp",
- "benchmark/src/main.cpp",
"benchmark/src/mbgl/benchmark/benchmark.cpp",
"benchmark/util/dtoa.benchmark.cpp",
"benchmark/util/tilecover.benchmark.cpp"
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/benchmark/src/main.cpp b/platform/default/src/mbgl/benchmark/main.cpp
index afe785140f..afe785140f 100644
--- a/benchmark/src/main.cpp
+++ b/platform/default/src/mbgl/benchmark/main.cpp
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}"
)