summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml1
-rw-r--r--CMakeLists.txt5
-rw-r--r--Makefile10
-rw-r--r--benchmark/parse/filter.benchmark.cpp (renamed from benchmark/parse/filter.cpp)0
-rw-r--r--cmake/benchmark-files.cmake15
-rw-r--r--cmake/benchmark.cmake32
-rw-r--r--platform/linux/config.cmake18
-rwxr-xr-xscripts/generate-benchmark-files.sh20
8 files changed, 101 insertions, 0 deletions
diff --git a/.travis.yml b/.travis.yml
index 793f0130d6..6c749acfdf 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -45,6 +45,7 @@ before_script:
- cmake --version
script:
- make linux
+ - make benchmark
- make test
- make run-test
after_script:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 79c85829e1..d021c856fb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,6 +59,11 @@ if(COMMAND mbgl_platform_test)
include(cmake/test.cmake)
endif()
+if(COMMAND mbgl_platform_benchmark)
+ include(cmake/benchmark-files.cmake)
+ include(cmake/benchmark.cmake)
+endif()
+
if(COMMAND mbgl_platform_glfw)
include(cmake/glfw.cmake)
endif()
diff --git a/Makefile b/Makefile
index 0f4cefa4b9..6d191d80f9 100644
--- a/Makefile
+++ b/Makefile
@@ -285,6 +285,10 @@ linux: glfw-app render offline
test: $(LINUX_BUILD)
$(NINJA) $(NINJA_ARGS) -j$(JOBS) -C $(LINUX_OUTPUT_PATH) mbgl-test
+.PHONY: benchmark
+benchmark: $(LINUX_BUILD)
+ $(NINJA) $(NINJA_ARGS) -j$(JOBS) -C $(LINUX_OUTPUT_PATH) mbgl-benchmark
+
ifneq (,$(shell which gdb))
GDB = gdb -batch -return-child-result -ex 'set print thread-events off' -ex 'run' -ex 'thread apply all bt' --args
endif
@@ -295,6 +299,12 @@ run-test: run-test-*
run-test-%: test
$(GDB) $(LINUX_OUTPUT_PATH)/mbgl-test --gtest_catch_exceptions=0 --gtest_filter=$*
+.PHONY: run-benchmark
+run-benchmark: run-benchmark-.
+
+run-benchmark-%: benchmark
+ $(GDB) $(LINUX_OUTPUT_PATH)/mbgl-benchmark --benchmark_filter=$*
+
.PHONY: render
render: $(LINUX_BUILD)
$(NINJA) $(NINJA_ARGS) -j$(JOBS) -C $(LINUX_OUTPUT_PATH) mbgl-render
diff --git a/benchmark/parse/filter.cpp b/benchmark/parse/filter.benchmark.cpp
index 5214f682d6..5214f682d6 100644
--- a/benchmark/parse/filter.cpp
+++ b/benchmark/parse/filter.benchmark.cpp
diff --git a/cmake/benchmark-files.cmake b/cmake/benchmark-files.cmake
new file mode 100644
index 0000000000..4e3045647d
--- /dev/null
+++ b/cmake/benchmark-files.cmake
@@ -0,0 +1,15 @@
+# Do not edit. Regenerate this with ./scripts/generate-benchmark-files.sh
+
+set(MBGL_BENCHMARK_FILES
+ # include/mbgl
+ benchmark/include/mbgl/benchmark.hpp
+
+ # parse
+ benchmark/parse/filter.benchmark.cpp
+
+ # src
+ benchmark/src/main.cpp
+
+ # src/mbgl/benchmark
+ benchmark/src/mbgl/benchmark/benchmark.cpp
+)
diff --git a/cmake/benchmark.cmake b/cmake/benchmark.cmake
new file mode 100644
index 0000000000..79da54459e
--- /dev/null
+++ b/cmake/benchmark.cmake
@@ -0,0 +1,32 @@
+add_executable(mbgl-benchmark
+ ${MBGL_BENCHMARK_FILES}
+)
+
+target_compile_options(mbgl-benchmark
+ PRIVATE -fvisibility-inlines-hidden
+)
+
+target_include_directories(mbgl-benchmark
+ PRIVATE include
+ PRIVATE src # TODO: eliminate
+ PRIVATE benchmark/include
+ PRIVATE benchmark/src
+ PRIVATE platform/default
+)
+
+if(DEFINED ENV{CI})
+ target_compile_definitions(mbgl-benchmark
+ PRIVATE -DCI_BUILD=1
+ )
+endif()
+
+target_link_libraries(mbgl-benchmark
+ PRIVATE mbgl-core
+)
+
+target_add_mason_package(mbgl-benchmark PRIVATE benchmark)
+target_add_mason_package(mbgl-benchmark PRIVATE rapidjson)
+
+mbgl_platform_benchmark()
+
+create_source_groups(mbgl-benchmark)
diff --git a/platform/linux/config.cmake b/platform/linux/config.cmake
index 24bb5ede0c..050a03bcb2 100644
--- a/platform/linux/config.cmake
+++ b/platform/linux/config.cmake
@@ -7,6 +7,7 @@ mason_use(libpng VERSION 1.6.25)
mason_use(libjpeg-turbo VERSION 1.5.0)
mason_use(webp VERSION 0.5.1)
mason_use(gtest VERSION 1.7.0${MASON_CXXABI_SUFFIX})
+mason_use(benchmark VERSION 1.0.0)
include(cmake/loop-uv.cmake)
@@ -102,6 +103,23 @@ macro(mbgl_platform_test)
endmacro()
+macro(mbgl_platform_benchmark)
+ target_sources(mbgl-benchmark
+ PRIVATE benchmark/src/main.cpp
+ )
+
+ set_source_files_properties(
+ benchmark/src/main.cpp
+ PROPERTIES
+ COMPILE_FLAGS -DWORK_DIRECTORY="${CMAKE_SOURCE_DIR}"
+ )
+
+ target_link_libraries(mbgl-benchmark
+ PRIVATE mbgl-loop
+ )
+endmacro()
+
+
macro(mbgl_platform_node)
# Enabling node module by defining this macro
endmacro()
diff --git a/scripts/generate-benchmark-files.sh b/scripts/generate-benchmark-files.sh
new file mode 100755
index 0000000000..0fb274cf31
--- /dev/null
+++ b/scripts/generate-benchmark-files.sh
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+
+set -e
+set -o pipefail
+
+echo "# Do not edit. Regenerate this with ./scripts/generate-benchmark-files.sh" > cmake/benchmark-files.cmake
+echo "" >> cmake/benchmark-files.cmake
+echo "set(MBGL_BENCHMARK_FILES" >> cmake/benchmark-files.cmake
+PREFIX=
+for FILE in $(git ls-files "benchmark/*.hpp" "benchmark/*.cpp" "benchmark/*.h" "benchmark/*.c" | sort) ; do
+ CURRENT_PREFIX=$(dirname ${FILE#benchmark/})
+ if [ "${PREFIX}" != "${CURRENT_PREFIX}" ]; then
+ if [ ! -z "${PREFIX}" ]; then echo "" >> cmake/benchmark-files.cmake ; fi
+ echo " # ${CURRENT_PREFIX}" >> cmake/benchmark-files.cmake
+ PREFIX="${CURRENT_PREFIX}"
+ fi
+ echo " ${FILE}" >> cmake/benchmark-files.cmake
+done
+echo ")" >> cmake/benchmark-files.cmake
+git diff cmake/benchmark-files.cmake