-
Notifications
You must be signed in to change notification settings - Fork 2
ci: add continuous benchmark report #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b69bb49
ci: add continuous benchmark action
WiseMrMusa b8ffa22
ci: add concurrency and timeout
WiseMrMusa 3d43207
feat: add sample benchmark
WiseMrMusa faf436b
chore: sort workspace dependencies
WiseMrMusa 7c04bf0
chore: use criterion for benchmark
WiseMrMusa 0cc9dd7
chore: revert back to cargo
WiseMrMusa 8eec963
Build benchmarks in GitHub actions
WiseMrMusa f3fb57b
Add all-targets
WiseMrMusa 2afb7dc
chore: remove generated benchmark data
WiseMrMusa adb530a
ci: fix rebase issues
WiseMrMusa 1b9ce60
ci: fix stale benchmark cache
WiseMrMusa d022bb0
fix: enable pipefail
WiseMrMusa 94e4b25
ci: improve workflow
WiseMrMusa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # TODO(template) this workflow requires a `gh-pages` branch to exist. | ||
| # Create it once with: | ||
| # git checkout --orphan gh-pages | ||
| # git reset --hard | ||
| # git commit --allow-empty -m "init gh-pages" | ||
| # git push origin gh-pages | ||
| # | ||
| # The benchmark dashboard will be available at: | ||
| # https://<org>.github.io/<repo>/dev/bench/ | ||
| name: Benchmarks | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| pull_request: | ||
| branches: ["main"] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| permissions: | ||
| contents: write | ||
| deployments: write | ||
| pull-requests: write | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
| CARGO_INCREMENTAL: 0 | ||
| CARGO_NET_RETRY: 10 | ||
| RUSTUP_MAX_RETRIES: 10 | ||
|
|
||
| jobs: | ||
| benchmark: | ||
| name: Continuous benchmarking | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/bin/ | ||
| ~/.cargo/registry/index/ | ||
| ~/.cargo/registry/cache/ | ||
| ~/.cargo/git/db/ | ||
| target/ | ||
| key: ${{ runner.os }}-bench-${{ hashFiles('**/Cargo.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-bench- | ||
|
|
||
| # TODO(template) update the bench command if you use a different | ||
| # benchmark harness or need to pass extra flags | ||
| - name: Run benchmarks | ||
| run: cargo bench -p template_crate --bench benchmark -- --output-format bencher 2>&1 | tee benchmark-output.txt | ||
|
|
||
| # On PRs: compare against cached baseline to detect regressions | ||
| - name: Download previous benchmark data | ||
| if: github.event_name == 'pull_request' | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ./cache | ||
| key: ${{ runner.os }}-benchmark | ||
WiseMrMusa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - name: Store benchmark result (PR) | ||
| if: github.event_name == 'pull_request' | ||
| uses: benchmark-action/github-action-benchmark@v1 | ||
| with: | ||
| # TODO(template) update the name to match your project | ||
| name: Benchmark | ||
| tool: "cargo" | ||
| output-file-path: benchmark-output.txt | ||
| external-data-json-path: ./cache/benchmark-data.json | ||
| alert-threshold: "130%" | ||
| comment-on-alert: true | ||
| fail-on-alert: true | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| # On main: push results to gh-pages for the historical dashboard | ||
| - name: Store benchmark result (main) | ||
| if: github.event_name == 'push' | ||
| uses: benchmark-action/github-action-benchmark@v1 | ||
| with: | ||
| # TODO(template) update the name to match your project | ||
| name: Rust Template Benchmark | ||
| tool: "cargo" | ||
| output-file-path: benchmark-output.txt | ||
| gh-pages-branch: gh-pages | ||
| benchmark-data-dir-path: dev/bench | ||
| alert-threshold: "130%" | ||
| comment-on-alert: true | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| auto-push: true | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| //! Benchmarks for template_crate | ||
|
|
||
| use criterion::{Criterion, black_box, criterion_group}; | ||
| use template_crate::{add_small_integers, sub_small_integers}; | ||
|
|
||
| /// Benchmarks for `add_small_integers` function | ||
| fn bench_add_small_integers(c: &mut Criterion) { | ||
| c.bench_function("add_small_integers valid", |b| { | ||
| b.iter(|| add_small_integers(black_box(50), black_box(30))) | ||
| }); | ||
|
|
||
| c.bench_function("add_small_integers bound check", |b| { | ||
| b.iter(|| add_small_integers(black_box(200), black_box(5))) | ||
| }); | ||
| } | ||
|
|
||
| /// Benchmarks for `sub_small_integers` function | ||
| fn bench_sub_small_integers(c: &mut Criterion) { | ||
| c.bench_function("sub_small_integers valid", |b| { | ||
| b.iter(|| sub_small_integers(black_box(50), black_box(30))) | ||
| }); | ||
|
|
||
| c.bench_function("sub_small_integers bound check", |b| { | ||
| b.iter(|| sub_small_integers(black_box(200), black_box(5))) | ||
| }); | ||
| } | ||
|
|
||
| /// Entry point for benchmarks | ||
| fn main() { | ||
| criterion_group!(benches, bench_add_small_integers, bench_sub_small_integers); | ||
| benches(); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.