Add a benchmark which uses Google benchmark library #17
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: ["master"] | |
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 | |
- name: Checkout benchmark results from docs repo | |
if: github.ref == 'refs/heads/master' | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
with: | |
repository: PcapPlusPlus/pcapplusplus.github.io | |
path: Benchmarks | |
sparse-checkout: benchmark-results | |
# 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 | |
- 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 PcapPlusPlus benchmark | |
run: cd Benchmarks && ./Bin/PcppBenchmark --benchmark_out=benchmark-results/benchmark_result_${GITHUB_SHA}.json | |
- name: Upload benchmark results | |
if: github.ref == 'refs/heads/master' | |
uses: cpina/github-action-push-to-another-repository@07c4d7b3def0a8ebe788a8f2c843a4e1de4f6900 # main | |
env: | |
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} | |
with: | |
source-directory: Benchmarks/benchmark-results | |
destination-github-username: "PcapPlusPlus" | |
destination-repository-name: "pcapplusplus.github.io" | |
user-email: [email protected] | |
commit-message: Add benchmark for commit ORIGIN_COMMIT | |
target-branch: master | |
target-directory: benchmark-results | |
- name: Save Ccache | |
uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
with: | |
path: ${{ env.CCACHE_DIR }} | |
key: ${{ steps.ccache-restore.outputs.cache-primary-key }} |