C++ example for benchmarking with Catch2 Framework
This directory shows how to use github-action-benchmark
with Catch2 Framework.
Official documentation for usage of Catch2 Framework can be found in its repository:
https://github.com/catchorg/Catch2
Since Catch2 is a header-only test framework, you don't need to build it in advance.
Download and put the headers in your include
directory and write your benchmarks.
#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
TEST_CASE("Fibonacci") {
// now let's benchmark:
BENCHMARK("Some benchmark") {
// Your benchmark goes here
};
}
Build the source with C++ compiler and run the built executable to get the benchmark output.
Ensure to use console
reporter for this. xml
reporter may be supported in the future.
Store the benchmark results with step using the action. Please set catch2
to tool
input.
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
tool: 'catch2'
output-file-path: benchmark_result.json
Please read 'How to use' section for common usage.
To try this example, please use cmake and clang++
.
$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ cmake --build . --config Release
This will create Catch2_bench
executable. The results are output to stdout.