From 8c3b7a1d4b47c48a9396b29985574f7205c46e08 Mon Sep 17 00:00:00 2001 From: Daniel Sipka Date: Fri, 2 Oct 2015 14:29:15 +0200 Subject: [PATCH] replace benchpress with google benchmark --- .gitmodules | 6 +++--- CMakeLists.txt | 3 ++- test/CMakeLists.txt | 4 ++-- test/benchmark_main.cpp | 16 ++++++++-------- vendor/benchmark | 1 + vendor/benchpress | 1 - 6 files changed, 16 insertions(+), 15 deletions(-) create mode 160000 vendor/benchmark delete mode 160000 vendor/benchpress diff --git a/.gitmodules b/.gitmodules index 4da6987..28ae018 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,6 +7,6 @@ [submodule "vendor/spec"] path = vendor/spec url = https://github.com/mustache/spec.git -[submodule "vendor/benchpress"] - path = vendor/benchpress - url = https://github.com/bigdatadev/benchpress.git +[submodule "vendor/benchmark"] + path = vendor/benchmark + url = https://github.com/google/benchmark.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 8868cf7..b3f9b43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ if(WITH_UNIT_TESTS) include_directories( vendor/Catch/single_include vendor/json.hpp/include - vendor/benchpress/src/benchpress) + vendor/benchmark/include) + add_subdirectory(vendor/benchmark) add_subdirectory(test) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1912938..1b55bf7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,8 +4,8 @@ include_directories( ${CMAKE_SOURCE_DIR}/include ${Boost_INCLUDE_DIR}) -add_executable(benchmark benchmark_main.cpp) -target_link_libraries(benchmark mstch) +add_executable(mstch_benchmark benchmark_main.cpp) +target_link_libraries(mstch_benchmark mstch benchmark) add_executable(headerize headerize.cpp) target_link_libraries(headerize ${Boost_PROGRAM_OPTIONS_LIBRARY}) diff --git a/test/benchmark_main.cpp b/test/benchmark_main.cpp index 913b2cc..ad7f8d5 100644 --- a/test/benchmark_main.cpp +++ b/test/benchmark_main.cpp @@ -1,10 +1,8 @@ -#define BENCHPRESS_CONFIG_MAIN - -#include +#include #include "mstch/mstch.hpp" -benchpress::auto_register basic_usage("basic usage", [](benchpress::context* ctx) { +static void basic_usage(benchmark::State& state) { std::string comment_tmp{ "

{{header}}

    " "{{#comments}}
  • {{name}}
    " @@ -19,8 +17,10 @@ benchpress::auto_register basic_usage("basic usage", [](benchpress::context* ctx mstch::map{{"name", std::string{"Kathy"}}, {"body", std::string{"Thanks for this post!"}}}, mstch::map{{"name", std::string{"George"}}, {"body", std::string{"Thanks for this post!"}}}}}}; - ctx->reset_timer(); - - for (size_t i = 0; i < ctx->num_iterations(); ++i) + while (state.KeepRunning()) mstch::render(comment_tmp, comment_view); -}); +} + +BENCHMARK(basic_usage); + +BENCHMARK_MAIN(); diff --git a/vendor/benchmark b/vendor/benchmark new file mode 160000 index 0000000..cf40a0f --- /dev/null +++ b/vendor/benchmark @@ -0,0 +1 @@ +Subproject commit cf40a0f1172afc061e910eb5590f71e6ffdece66 diff --git a/vendor/benchpress b/vendor/benchpress deleted file mode 160000 index 469b7c6..0000000 --- a/vendor/benchpress +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 469b7c6b0b582389fa397d9b990a0ff1c3b93462