Skip to content

Commit 1601f96

Browse files
committed
first commit
0 parents commit 1601f96

File tree

7 files changed

+117
-0
lines changed

7 files changed

+117
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.pb*
2+
Debug
3+
Release
4+
bin
5+
obj
6+
*.suo
7+
*.sdf
8+
*.vcxproj.user
9+
build

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "benchmark"]
2+
path = benchmark
3+
url = https://github.com/google/benchmark.git

CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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()

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+

benchmark

Submodule benchmark added at 0811f1d
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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)

src/main.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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();

0 commit comments

Comments
 (0)