Add a benchmark which uses Google benchmark library #15
Workflow file for this run
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
name: Benchmark | |
on: | |
pull_request: | |
branches: ["dev"] | |
push: | |
branches: ["dev"] | |
env: | |
BUILD_DIR: Dist | |
CCACHE_DIR: ${{ github.workspace }}/.ccache | |
permissions: | |
contents: read | |
jobs: | |
benchmark: | |
runs-on: ubuntu-latest | |
container: seladb/ubuntu2204 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
# Checkout is performed out of the container and doesn't match our user | |
- name: Fix checkout ownership | |
run: chown -R "$(id -u):$(id -g)" "$GITHUB_WORKSPACE" | |
- name: Restore Ccache | |
id: ccache-restore | |
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
with: | |
path: | | |
${{ env.CCACHE_DIR }} | |
key: ubuntu2204-ccache-${{ github.run_id }} | |
restore-keys: | | |
ubuntu2204-ccache | |
- uses: bencherdev/bencher@dfb22ab380d7e985394c23a459ee3586e7a16a98 # v0.4.19 | |
- name: Install dependencies (remove and install this to the container) | |
run: apt-get update && apt-get install -y libbenchmark-dev | |
- name: Configure PcapPlusPlus for benchmarking | |
run: cmake -DPCAPPP_BUILD_BENCHMARK_SUITE=ON -S . -B "$BUILD_DIR" | |
- name: Build PcapPlusPlus | |
run: cmake --build "$BUILD_DIR" -j | |
- name: Run benchmark with Bencher | |
run: | | |
bencher run \ | |
--project PcapPlusPlus \ | |
--token '${{ secrets.BENCHER_API_TOKEN }}' \ | |
--branch dev \ | |
--testbed ubuntu2204 \ | |
--adapter cpp_google \ | |
"cd Benchmarks && ./Bin/PcppBenchmark --benchmark_out=benchmark_result.json" | |
- name: Save Ccache | |
uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
with: | |
path: ${{ env.CCACHE_DIR }} | |
key: ${{ steps.ccache-restore.outputs.cache-primary-key }} |