Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build --//core:codspeed_mode=instrumentation
build --compilation_mode=dbg
build --copt=-O2
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.6.1
5 changes: 5 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
Language: Cpp
BasedOnStyle: Google
PointerAlignment: Left
...
205 changes: 99 additions & 106 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,111 +10,104 @@ jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Cache build
uses: actions/cache@v3
with:
path: core/build-tests
key: ${{ runner.os }}-build-tests-${{ hashFiles('**/CMakeLists.txt', '**/examples/google_benchmark/**') }}

- name: Create build directory
run: mkdir -p core/build-tests

- name: Build tests
run: |
cd core/build-tests
cmake .. -DENABLE_TESTS=ON
make -j

- name: Run tests
run: |
cd core/build-tests
GTEST_OUTPUT=json:test-results/ ctest

- name: Upload test results
uses: actions/upload-artifact@v4
if: failure()
with:
name: test_results
path: ${{runner.workspace}}/core/build-tests/test/test-results/**/*.json

instrumentation:
runs-on: ubuntu-latest

- name: Checkout code
uses: actions/checkout@v3

- name: Cache build
uses: actions/cache@v3
with:
path: core/build-tests
key: ${{ runner.os }}-build-tests-${{ hashFiles('**/CMakeLists.txt') }}

- name: Create build directory
run: mkdir -p core/build-tests

- name: Build tests
run: |
cd core/build-tests
cmake .. -DENABLE_TESTS=ON
make -j

- name: Run tests
run: |
cd core/build-tests
GTEST_OUTPUT=json:test-results/ ctest

- name: Upload test results
uses: actions/upload-artifact@v4
if: failure()
with:
name: test_results
path: ${{runner.workspace}}/core/build-tests/test/test-results/**/*.json

cmake-integration-tests:
strategy:
matrix:
include:
- codspeed-mode: "instrumentation"
runner: "ubuntu-latest"
- codspeed-mode: "walltime"
runner: "codspeed-macro"
- codspeed-mode: "off"
runner: "ubuntu-latest"
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Cache build
uses: actions/cache@v3
with:
path: examples/google_benchmark/build-instrumentation
key: ${{ runner.os }}-build-instrumentation-${{ hashFiles('**/CMakeLists.txt', '**/examples/google_benchmark/**') }}

- name: Create build directory
run: mkdir -p examples/google_benchmark/build-instrumentation

- name: Build instrumentation benchmark example
run: |
cd examples/google_benchmark/build-instrumentation
cmake -DCODSPEED_MODE=instrumentation ..
make -j

- name: Run the benchmarks
uses: CodSpeedHQ/action@main
with:
run: examples/google_benchmark/build-instrumentation/benchmark_example
token: ${{ secrets.CODSPEED_TOKEN }}

walltime:
runs-on: codspeed-macro

- name: Checkout code
uses: actions/checkout@v3

- name: Cache build
uses: actions/cache@v3
with:
path: examples/google_benchmark_cmake/build
key: ${{ runner.os }}-build-${{ matrix.codspeed-mode }}-${{ hashFiles('**/CMakeLists.txt') }}

- name: Create build directory
run: mkdir -p examples/google_benchmark_cmake/build

- name: Build benchmark example
run: |
cd examples/google_benchmark_cmake/build
cmake -DCODSPEED_MODE=${{ matrix.codspeed-mode }} ..
make -j

- name: Run the benchmarks
uses: CodSpeedHQ/action@main
if: matrix.codspeed-mode != 'off'
with:
run: examples/google_benchmark_cmake/build/benchmark_example
token: ${{ secrets.CODSPEED_TOKEN }}

bazel-integration-tests:
strategy:
matrix:
include:
- codspeed-mode: "instrumentation"
runner: "ubuntu-latest"
- codspeed-mode: "walltime"
runner: "codspeed-macro"
- codspeed-mode: "off"
runner: "ubuntu-latest"
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Cache build
uses: actions/cache@v3
with:
path: examples/google_benchmark/build-walltime
key: ${{ runner.os }}-build-walltime-${{ hashFiles('**/CMakeLists.txt', '**/examples/google_benchmark/**') }}

- name: Create build directory
run: mkdir -p examples/google_benchmark/build-walltime

- name: Build walltime benchmark example
run: |
cd examples/google_benchmark/build-walltime
cmake -DCODSPEED_MODE=walltime ..
make -j

- name: Run the benchmarks
uses: CodSpeedHQ/action@main
with:
run: examples/google_benchmark/build-walltime/benchmark_example
token: ${{ secrets.CODSPEED_TOKEN }}


build-no-codspeed:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Cache build
uses: actions/cache@v3
with:
path: examples/google_benchmark/build-no-codspeed
key: ${{ runner.os }}-build-no-codspeed-${{ hashFiles('**/CMakeLists.txt', '**/examples/google_benchmark/**') }}

- name: Create build directory
run: mkdir -p examples/google_benchmark/build-no-codspeed

- name: Build benchmark example without codspeed
run: |
cd examples/google_benchmark/build-no-codspeed
cmake ..
make -j
- uses: actions/checkout@v4

- name: Set up Bazel
uses: bazel-contrib/[email protected]
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per workflow.
disk-cache: ${{ github.workflow }}
# Share repository cache between workflows.
repository-cache: true

- name: Build and run benchmarks
run: |
bazel build //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }}

- name: Run the benchmarks
uses: CodSpeedHQ/action@main
if: matrix.codspeed-mode != 'off'
with:
run: bazel run //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }}
token: ${{ secrets.CODSPEED_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ build/

# Clangd cache
.cache/

# Bazel output
/bazel-*
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bazel_dep(name = "rules_cc", version = "0.0.17")
126 changes: 126 additions & 0 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ This mono-repo contains the integration libraries for using CodSpeed in C++:

- [`codspeed-google-benchmark`](./google_benchmark/): Google Benchmark compatibility layer for CodSpeed
- [`codspeed-core`](./core/): The CodSpeed core library used to integrate with Codspeed runners

## Usage

The library can be used with both [CMake](https://docs.codspeed.io/benchmarks/cpp#cmake) and [Bazel](https://docs.codspeed.io/benchmarks/cpp#bazel). If you need further information to integrate CodSpeed to your project, please feel free to open an issue or ask for help on our discord server.
Loading