Skip to content

Commit

Permalink
Benchmark vector and matrix separately and upload the report to GH pages
Browse files Browse the repository at this point in the history
  • Loading branch information
cm-jones committed Jun 29, 2024
1 parent db5142c commit 783901d
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 37 deletions.
70 changes: 50 additions & 20 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,64 @@ on:

jobs:
benchmark:
name: Run benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake g++ libgtest-dev
- name: Build and Install GTest
run: |
cd /usr/src/gtest
sudo cmake CMakeLists.txt
sudo make
sudo cp lib/*.a /usr/lib
sudo apt-get install -y cmake g++
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release

- name: Build
run: cmake --build ${{github.workspace}}/build --config Release

- name: Run benchmarks
working-directory: ${{github.workspace}}/build
run: ./benchmark_vector --benchmark_format=console --benchmark_out=benchmark_results.txt

- name: Upload benchmark results
uses: actions/upload-artifact@v2

- name: Run matrix benchmark
run: ${{github.workspace}}/build/benchmark_matrix --benchmark_format=json --benchmark_out=matrix_benchmark_result.json

- name: Run vector benchmark
run: ${{github.workspace}}/build/benchmark_vector --benchmark_format=json --benchmark_out=vector_benchmark_result.json

- name: Store matrix benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: Matrix Benchmark
tool: 'googlecpp'
output-file-path: matrix_benchmark_result.json
github-token: ${{ secrets.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

- name: Store vector benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: Vector Benchmark
tool: 'googlecpp'
output-file-path: vector_benchmark_result.json
github-token: ${{ secrets.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

- name: Copy latest benchmark results
run: |
mkdir -p ./public/dev/bench
cp matrix_benchmark_result.json ./public/dev/bench/latest-matrix-result.json
cp vector_benchmark_result.json ./public/dev/bench/latest-vector-result.json
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
name: benchmark-results
path: ${{github.workspace}}/build/benchmark_results.txt
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
destination_dir: dev/bench
21 changes: 12 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ enable_testing()
add_executable(cramer_tests
tests/test_vector.cpp
tests/test_matrix.cpp
# Add other test files here
)
target_link_libraries(cramer_tests
PRIVATE
Expand All @@ -64,19 +63,23 @@ FetchContent_Declare(
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(benchmark)

# Add combined benchmark executable
add_executable(benchmark_all
benchmarks/benchmark_main.cpp
benchmarks/benchmark_vector.cpp
# Add matrix benchmark executable
add_executable(benchmark_matrix
benchmarks/benchmark_matrix.cpp
)
target_include_directories(benchmark_all PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/benchmarks
target_link_libraries(benchmark_matrix PRIVATE
cramer
benchmark::benchmark
)

# Add vector benchmark executable
add_executable(benchmark_vector
benchmarks/benchmark_vector.cpp
)
target_link_libraries(benchmark_all PRIVATE
target_link_libraries(benchmark_vector PRIVATE
cramer
benchmark::benchmark
)

# Make sure all targets are built by default
add_custom_target(build_all ALL DEPENDS cramer cramer_tests benchmark_all)
add_custom_target(build_all ALL DEPENDS cramer cramer_tests benchmark_matrix benchmark_vector)
8 changes: 0 additions & 8 deletions benchmarks/benchmark_main.cpp

This file was deleted.

0 comments on commit 783901d

Please sign in to comment.