-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Catch2 C++ Example | ||
on: push | ||
|
||
jobs: | ||
benchmark: | ||
name: Run C++ benchmark example | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: | | ||
cd examples/catch2 | ||
mkdir build && cd build | ||
cmake -DCMAKE_BUILD_TYPE=Release .. | ||
cmake --build . --config Release | ||
./Catch2_bench > ../benchmark_result.txt | ||
- name: Store benchmark result | ||
uses: ./ | ||
with: | ||
name: Catch2 Benchmark | ||
tool: "catch2" | ||
output-file-path: examples/catch2/benchmark_result.txt | ||
# Use personal access token instead of GITHUB_TOKEN due to https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/td-p/26869/highlight/false | ||
github-token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} | ||
auto-push: true | ||
# Show alert with commit comment on detecting possible performance regression | ||
alert-threshold: "200%" | ||
comment-on-alert: true | ||
fail-on-alert: true | ||
alert-comment-cc-users: "@bernedom" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
project("Catch2_bench") | ||
|
||
include(FetchContent) | ||
|
||
FetchContent_Declare( | ||
catch2 | ||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git | ||
GIT_TAG v2.11.0) | ||
|
||
FetchContent_GetProperties(catch2) | ||
if(NOT catch2_POPULATED) | ||
FetchContent_Populate(catch2) | ||
add_subdirectory(${catch2_SOURCE_DIR} ${catch2_BINARY_DIR}) | ||
endif() | ||
|
||
add_executable(${PROJECT_NAME}) | ||
target_sources(${PROJECT_NAME} PRIVATE catch2_bench.cpp) | ||
target_link_libraries(${PROJECT_NAME} Catch2::Catch2) | ||
|
||
target_compile_options( | ||
${PROJECT_NAME} | ||
PRIVATE | ||
$<$<CXX_COMPILER_ID:MSVC>:/DCATCH_CONFIG_ENABLE_BENCHMARKING> | ||
$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-DCATCH_CONFIG_ENABLE_BENCHMARKING> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "fib.hpp" | ||
#define CATCH_CONFIG_MAIN | ||
#include <catch2/catch.hpp> | ||
|
||
TEST_CASE("Fibonacci") { | ||
|
||
// now let's benchmark: | ||
BENCHMARK("Fibonacci 20") { return fib(20); }; | ||
|
||
BENCHMARK("Fibonacci 25") { return fib(25); }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#if !defined FIB_HPP_INCLUDED | ||
#define FIB_HPP_INCLUDED | ||
|
||
int fib(int const i) { | ||
if (i <= 1) { | ||
return 1; | ||
} | ||
return fib(i - 2) + fib(i - 1); | ||
} | ||
|
||
#endif // FIB_HPP_INCLUDED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters