summaryrefslogtreecommitdiff
path: root/libcxx/benchmarks
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2018-11-14 20:38:46 +0000
committerEric Fiselier <eric@efcs.ca>2018-11-14 20:38:46 +0000
commit954bbb53329e08b8af991f31296a44cf85817b21 (patch)
tree4a9c29360247359767d68546237dc2598c0ee31b /libcxx/benchmarks
parentb776ce6714259df396df43c8e3a6396fd1789283 (diff)
Rename cxx-benchmark-unittests target and convert to LIT.
This patch renames the cxx-benchmark-unittests to check-cxx-benchmarks and converts the target to use LIT in order to make the tests run faster and provide better output. In particular this runs each benchmark in a suite one by one, allowing more parallelism while ensuring output isn't garbage with multiple threads. Additionally, it adds the CMake flag '-DLIBCXX_BENCHMARK_TEST_ARGS=<list>' to specify what options are passed when running the benchmarks.
Diffstat (limited to 'libcxx/benchmarks')
-rw-r--r--libcxx/benchmarks/CMakeLists.txt29
-rw-r--r--libcxx/benchmarks/lit.cfg.py23
-rw-r--r--libcxx/benchmarks/lit.site.cfg.py.in10
3 files changed, 51 insertions, 11 deletions
diff --git a/libcxx/benchmarks/CMakeLists.txt b/libcxx/benchmarks/CMakeLists.txt
index c5b4bf0fba1..893116142bd 100644
--- a/libcxx/benchmarks/CMakeLists.txt
+++ b/libcxx/benchmarks/CMakeLists.txt
@@ -180,15 +180,22 @@ foreach(test_path ${BENCHMARK_TESTS})
add_benchmark_test(${test_name} ${test_file})
endforeach()
+if (LIBCXX_INCLUDE_TESTS)
+ include(AddLLVM)
-add_custom_target(cxx-benchmark-unittests)
-foreach(libcxx_tg ${libcxx_benchmark_targets})
- message("Adding test ${libcxx_tg}")
- # Add a target that runs the benchmark for the smallest possible time, simply so we get test
- # and sanitizer coverage on the targets.
- add_custom_target(${libcxx_tg}_test
- COMMAND ${libcxx_tg} --benchmark_min_time=0.01
- COMMENT "Running test ${libcxx_tg}"
- )
- add_dependencies(cxx-benchmark-unittests ${libcxx_tg}_test)
-endforeach()
+ if (NOT DEFINED LIBCXX_TEST_DEPS)
+ message(FATAL_ERROR "Expected LIBCXX_TEST_DEPS to be defined")
+ endif()
+
+ configure_lit_site_cfg(
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
+ ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py)
+
+ set(BENCHMARK_LIT_ARGS "--show-all --show-xfail --show-unsupported ${LIT_ARGS_DEFAULT}")
+
+ add_lit_testsuite(check-cxx-benchmarks
+ "Running libcxx benchmarks tests"
+ ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS cxx-benchmarks ${LIBCXX_TEST_DEPS}
+ ARGS ${BENCHMARK_LIT_ARGS})
+endif()
diff --git a/libcxx/benchmarks/lit.cfg.py b/libcxx/benchmarks/lit.cfg.py
new file mode 100644
index 00000000000..84857d570d7
--- /dev/null
+++ b/libcxx/benchmarks/lit.cfg.py
@@ -0,0 +1,23 @@
+# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
+# Configuration file for the 'lit' test runner.
+import os
+import site
+
+site.addsitedir(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'utils'))
+from libcxx.test.googlebenchmark import GoogleBenchmark
+
+# Tell pylint that we know config and lit_config exist somewhere.
+if 'PYLINT_IMPORT' in os.environ:
+ config = object()
+ lit_config = object()
+
+# name: The name of this test suite.
+config.name = 'libc++ benchmarks'
+config.suffixes = []
+
+config.test_exec_root = os.path.join(config.libcxx_obj_root, 'benchmarks')
+config.test_source_root = config.test_exec_root
+
+config.test_format = GoogleBenchmark(test_sub_dirs='.',
+ test_suffix='.libcxx.out',
+ benchmark_args=config.benchmark_args) \ No newline at end of file
diff --git a/libcxx/benchmarks/lit.site.cfg.py.in b/libcxx/benchmarks/lit.site.cfg.py.in
new file mode 100644
index 00000000000..e3ce8b22263
--- /dev/null
+++ b/libcxx/benchmarks/lit.site.cfg.py.in
@@ -0,0 +1,10 @@
+@LIT_SITE_CFG_IN_HEADER@
+
+import sys
+
+config.libcxx_src_root = "@LIBCXX_SOURCE_DIR@"
+config.libcxx_obj_root = "@LIBCXX_BINARY_DIR@"
+config.benchmark_args = "@LIBCXX_BENCHMARK_TEST_ARGS@".split(';')
+
+# Let the main config do the real work.
+lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/benchmarks/lit.cfg.py") \ No newline at end of file