Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

C++ example for benchmarking with Catch2 Framework

This directory shows how to use github-action-benchmark with Catch2 Framework.

Run benchmarks

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.

Process benchmark results

Store the benchmark results with step using the action. Please set catch2 to tool input.

- name: Store benchmark result
  uses: rhysd/github-action-benchmark@v1
  with:
    tool: 'catch2'
    output-file-path: benchmark_result.json

Please read 'How to use' section for common usage.

Run this example

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.