Skip to content

Commit 3d6c3a6

Browse files
Merge pull request #23 from theseus-rs/refactor-benchmarking
refactor: refactor the way benchmarks run on the main branch vs a PR
2 parents 7aec4b3 + d0defdd commit 3d6c3a6

File tree

2 files changed

+49
-13
lines changed

2 files changed

+49
-13
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010

1111
permissions:
1212
contents: read
13-
pull-requests: write
1413

1514
jobs:
1615
checks:
@@ -93,23 +92,15 @@ jobs:
9392
fail_ci_if_error: true
9493

9594
- name: Install benchmarking tools
96-
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
95+
if: ${{ github.ref == 'refs/heads/main' && startsWith(matrix.os, 'ubuntu-') }}
9796
uses: bencherdev/bencher@main
9897

9998
- name: Run benchmarks
100-
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
99+
if: ${{ github.ref == 'refs/heads/main' && startsWith(matrix.os, 'ubuntu-') }}
101100
env:
102101
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
103102
BENCHER_PROJECT: theseus-rs-postgresql-embedded
104103
BENCHER_ADAPTER: rust_criterion
105104
run: |
106-
cargo bench --bench archive --features blocking -- --output-format criterion | \
107-
bencher run \
108-
--ci-number "${{ github.event.number }}" \
109-
--github-actions "${{ secrets.GITHUB_TOKEN }}" \
110-
--err
111-
cargo bench --bench embedded --features blocking -- --output-format criterion | \
112-
bencher run \
113-
--ci-number "${{ github.event.number }}" \
114-
--github-actions "${{ secrets.GITHUB_TOKEN }}" \
115-
--err
105+
cargo bench --bench archive --features blocking -- --output-format criterion | bencher run
106+
cargo bench --bench embedded --features blocking -- --output-format criterion | bencher run

.github/workflows/pr-benchmarks.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Run and Cache Benchmarks
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
permissions:
8+
pull-requests: write
9+
10+
jobs:
11+
benchmark:
12+
name: Run Benchmarks
13+
runs-on: ubuntu-22.04
14+
steps:
15+
- name: Checkout source code
16+
uses: actions/checkout@v4
17+
18+
- name: Install Rust
19+
uses: dtolnay/rust-toolchain@master
20+
with:
21+
components: 'llvm-tools-preview'
22+
toolchain: stable
23+
24+
- name: Enable caching
25+
uses: Swatinem/rust-cache@v2
26+
27+
- name: Install benchmarking tools
28+
uses: bencherdev/bencher@main
29+
30+
- name: Run benchmarks
31+
env:
32+
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
33+
BENCHER_PROJECT: theseus-rs-postgresql-embedded
34+
BENCHER_ADAPTER: rust_criterion
35+
run: |
36+
cargo bench --bench archive --features blocking -- --output-format criterion | \
37+
bencher run \
38+
--ci-number "${{ github.event.number }}" \
39+
--github-actions "${{ secrets.GITHUB_TOKEN }}" \
40+
--err
41+
cargo bench --bench embedded --features blocking -- --output-format criterion | \
42+
bencher run \
43+
--ci-number "${{ github.event.number }}" \
44+
--github-actions "${{ secrets.GITHUB_TOKEN }}" \
45+
--err

0 commit comments

Comments
 (0)