File tree Expand file tree Collapse file tree 7 files changed +117
-0
lines changed Expand file tree Collapse file tree 7 files changed +117
-0
lines changed Original file line number Diff line number Diff line change 1+ * .pb *
2+ Debug
3+ Release
4+ bin
5+ obj
6+ * .suo
7+ * .sdf
8+ * .vcxproj.user
9+ build
Original file line number Diff line number Diff line change 1+ [submodule "benchmark "]
2+ path = benchmark
3+ url = https://github.com/google/benchmark.git
Original file line number Diff line number Diff line change 1+ cmake_minimum_required (VERSION 2.8)
2+ project (simple_benchmark_template CXX)
3+
4+ set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR} /cmake_modules" ${CMAKE_MODULE_PATH} )
5+ find_package (GoogleBenchmark REQUIRED)
6+
7+ set (BENCHMARK_INCLUDE_DIR "${CMAKE_SOURCE_DIR} /benchmark/include" )
8+ if ("${CMAKE_SYSTEM_NAME} " MATCHES "Windows" )
9+ if ("${CMAKE_BUILD_TYPE} " MATCHES "Release" )
10+ set (BENCHMARK_LIBRARIES "${CMAKE_SOURCE_DIR} /benchmark/build/src/Release/*.lib" )
11+ else ()
12+ set (BENCHMARK_LIBRARIES "${CMAKE_SOURCE_DIR} /benchmark/build/src/Debug/*.lib" )
13+ endif ()
14+ endif ()
15+ include_directories (${BENCHMARK_INCLUDE_DIR} )
16+ include_directories (headers)
17+
18+ file (GLOB_RECURSE SOURCE_FILES headers/* src/*)
19+
20+ add_executable (simple_benchmark_template ${SOURCE_FILES} )
21+
22+ target_link_libraries (simple_benchmark_template ${BENCHMARK_LIBRARIES} )
23+ if ("${CMAKE_SYSTEM_NAME} " MATCHES "Windows" )
24+ target_link_libraries (simple_benchmark_template Shlwapi)
25+ endif ()
Original file line number Diff line number Diff line change 1+ # simple_benchmark_template
2+ Simple Benchmark template
3+
4+ Fork from [ RichardDally/MicroBenchmark] ( https://github.com/RichardDally/MicroBenchmark )
5+
6+ ```
7+ git submodule update --init --recursive
8+ ```
9+
10+ Build benchmark Release and Debug
11+ ```
12+ cd benchmark
13+ mkdir build
14+ cd build
15+ cmake -G "Visual Studio 16 2019" ..
16+ ```
17+
18+ Build
19+ ```
20+ mkdir build
21+ cd build
22+ cmake -G "Visual Studio 16 2019" ..
23+ ```
24+
25+
Original file line number Diff line number Diff line change 1+ # Findbenchmark.cmake
2+ # - Try to find benchmark
3+ #
4+ # The following variables are optionally searched for defaults
5+ # benchmark_ROOT_DIR: Base directory where all benchmark components are found
6+ #
7+ # Once done this will define
8+ # benchmark_FOUND - System has benchmark
9+ # benchmark_INCLUDE_DIRS - The benchmark include directories
10+ # benchmark_LIBRARIES - The libraries needed to use benchmark
11+
12+ set (benchmark_ROOT_DIR "" CACHE PATH "Folder containing benchmark" )
13+
14+ find_path (benchmark_INCLUDE_DIR "benchmark/benchmark.h"
15+ PATHS ${benchmark_ROOT_DIR}
16+ PATH_SUFFIXES include
17+ NO_DEFAULT_PATH)
18+ find_path (benchmark_INCLUDE_DIR "benchmark/benchmark.h" )
19+
20+ find_library (benchmark_LIBRARY NAMES "benchmark"
21+ PATHS ${benchmark_ROOT_DIR}
22+ PATH_SUFFIXES lib lib64
23+ NO_DEFAULT_PATH)
24+ find_library (benchmark_LIBRARY NAMES "benchmark" )
25+
26+ include (FindPackageHandleStandardArgs)
27+ # handle the QUIETLY and REQUIRED arguments and set benchmark_FOUND to TRUE
28+ # if all listed variables are TRUE
29+ find_package_handle_standard_args(benchmark FOUND_VAR benchmark_FOUND
30+ REQUIRED_VARS benchmark_LIBRARY
31+ benchmark_INCLUDE_DIR)
32+
33+ if (benchmark_FOUND)
34+ set (benchmark_LIBRARIES ${benchmark_LIBRARY} )
35+ set (benchmark_INCLUDE_DIRS ${benchmark_INCLUDE_DIR} )
36+ endif ()
37+
38+ mark_as_advanced (benchmark_INCLUDE_DIR benchmark_LIBRARY)
Original file line number Diff line number Diff line change 1+ #include < benchmark\benchmark.h>
2+
3+ static void StandardString (benchmark::State& state) {
4+ if (state.thread_index == 0 ) {
5+ // Prepare
6+ }
7+ while (state.KeepRunning ()) {
8+ std::string myString;
9+ }
10+ if (state.thread_index == 0 ) {
11+ // Teardown
12+ }
13+ }
14+
15+ BENCHMARK (StandardString);
16+ BENCHMARK_MAIN ();
You can’t perform that action at this time.
0 commit comments