From 19d207e1c213aa9dd3a4ab077738784ca943dc3e Mon Sep 17 00:00:00 2001 From: Asuna Date: Thu, 13 Jun 2024 05:07:32 +0800 Subject: [PATCH] CI run benchmarks, record results, alert if threshold is exceeded --- .github/workflows/ci.yml | 33 +++++++++++++++++++++++++++++++++ spdlog/benches/README.md | 7 +++++++ 2 files changed, 40 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 062097c..697c781 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -196,3 +196,36 @@ jobs: run: cargo +nightly update -Z minimal-versions - name: Check MSRV for core with Rust ${{ env.rust_minver }} run: cargo +${{ env.rust_minver }} check --locked --all-features --verbose + + bench: + needs: [test, check] + strategy: + fail-fast: false + runs-on: 'ubuntu-latest' + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Disable bench dependencies + run: ./.github/workflows/disable-bench-deps.sh + - name: Install Rust nightly + run: rustup toolchain install nightly + - name: Restore cargo caches + uses: Swatinem/rust-cache@v2 + - name: Run benchmark + run: cargo +nightly bench --features "multi-thread,runtime-pattern" --bench spdlog_rs --bench spdlog_rs_pattern | tee bench-results.txt + - name: Discard irrelevant changes + run: git checkout -- spdlog/Cargo.toml + - name: Process results + uses: benchmark-action/github-action-benchmark@v1 + with: + name: spdlog-rs on Linux + tool: cargo + output-file-path: bench-results.txt + benchmark-data-dir-path: docs/dev/benchmarks + github-token: ${{ secrets.GITHUB_TOKEN }} + summary-always: true + comment-on-alert: true + alert-comment-cc-users: '@SpriteOvO' + - name: Push results to GitHub Pages branch + if: github.event_name != 'pull_request' && (github.ref_name == 'main' || github.ref_name == 'main-dev') + run: git push 'https://${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git' gh-pages:gh-pages diff --git a/spdlog/benches/README.md b/spdlog/benches/README.md index 4186936..83a1151 100644 --- a/spdlog/benches/README.md +++ b/spdlog/benches/README.md @@ -1,5 +1,11 @@ # Benchmarks +## Development + +[The tracking page] for benchmark changes for each commit during development. + +## Benchmarking locally + Run `cargo +nightly bench --features multi-thread` in the root directory of this repository for benchmarking. The following results are generated with `Windows 10 64 bit` and `Intel i9-10900KF CPU @ 3.70GHz`. @@ -281,4 +287,5 @@ test bench_5_level_off ... unavailable +[The tracking page]: https://spriteovo.github.io/spdlog-rs/dev/benchmarks/ [`4cfdc8c`]: https://github.com/gabime/spdlog/commit/4cfdc8c5c84f696774cb9acde2f95c9e87c11a5e