Skip to content

Commit 20afd03

Browse files
authored
Update benchmarks.yml
1 parent 7beb53a commit 20afd03

File tree

1 file changed

+58
-66
lines changed

1 file changed

+58
-66
lines changed

.github/workflows/benchmarks.yml

Lines changed: 58 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,81 +2,73 @@ name: Benchmarks
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches:
6+
- main
67
pull_request:
7-
branches: [ main ]
8-
schedule:
9-
- cron: '0 0 * * 0' # Run weekly on Sundays
10-
11-
env:
12-
CARGO_TERM_COLOR: always
13-
RUST_BACKTRACE: 1
8+
branches:
9+
- main
1410

1511
jobs:
16-
benchmarks:
17-
name: Run Benchmarks
12+
benchmark:
1813
runs-on: ubuntu-latest
14+
1915
steps:
20-
- uses: actions/checkout@v4
21-
22-
- name: Install Rust
23-
uses: dtolnay/rust-toolchain@stable
24-
with:
25-
profile: minimal
26-
toolchain: stable
27-
override: true
28-
29-
- name: Cache dependencies
30-
uses: actions/cache@v4
31-
with:
32-
path: |
33-
~/.cargo/registry
34-
~/.cargo/git
35-
target
36-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
37-
38-
- name: Install cargo-criterion
39-
run: cargo install cargo-criterion
40-
working-directory: .
41-
42-
- name: Run benchmarks
43-
run: cargo criterion
44-
working-directory: .
16+
- name: Checkout code
17+
uses: actions/checkout@v2
18+
19+
- name: Install Rust
20+
uses: actions-rs/toolchain@v1
21+
with:
22+
toolchain: stable
23+
override: true
24+
25+
- name: Install dependencies
26+
run: sudo apt-get update && sudo apt-get install -y libudev-dev
27+
28+
- name: Set environment variables
29+
run: |
30+
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
31+
export LD_LIBRARY_PATH=/usr/local/lib
32+
33+
- name: Run benchmarks
34+
run: |
35+
export RUST_BACKTRACE=full
36+
cargo bench
4537
46-
- name: Create benchmark results directory
47-
run: mkdir -p target/criterion
48-
working-directory: .
38+
- name: Create benchmark results directory
39+
run: mkdir -p target/criterion
40+
working-directory: .
4941

50-
- name: Upload benchmark results
51-
uses: actions/upload-artifact@v4
52-
with:
53-
name: benchmark-results
54-
path: target/criterion
55-
if-no-files-found: warn
42+
- name: Upload benchmark results
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: benchmark-results
46+
path: target/criterion
47+
if-no-files-found: warn
5648

57-
- name: Generate benchmark report
58-
run: |
59-
mkdir -p benchmark-report
60-
cp -r target/criterion/* benchmark-report/ || true
61-
echo "# Benchmark Results" > benchmark-report/README.md
62-
echo "Generated on $(date)" >> benchmark-report/README.md
63-
echo "## Summary" >> benchmark-report/README.md
64-
find target/criterion -name "*/new/estimates.json" -exec cat {} \; | jq -r '.mean | { command: .point_estimate, lower_bound: .confidence_interval.lower_bound, upper_bound: .confidence_interval.upper_bound }' >> benchmark-report/README.md || echo "No benchmark results found" >> benchmark-report/README.md
49+
- name: Generate benchmark report
50+
run: |
51+
mkdir -p benchmark-report
52+
cp -r target/criterion/* benchmark-report/ || true
53+
echo "# Benchmark Results" > benchmark-report/README.md
54+
echo "Generated on $(date)" >> benchmark-report/README.md
55+
echo "## Summary" >> benchmark-report/README.md
56+
find target/criterion -name "*/new/estimates.json" -exec cat {} \; | jq -r '.mean | { command: .point_estimate, lower_bound: .confidence_interval.lower_bound, upper_bound: .confidence_interval.upper_bound }' >> benchmark-report/README.md || echo "No benchmark results found" >> benchmark-report/README.md
6557
working-directory: .
6658
67-
- name: Upload benchmark report
68-
uses: actions/upload-artifact@v4
69-
with:
70-
name: benchmark-report
71-
path: benchmark-report
72-
if-no-files-found: warn
59+
- name: Upload benchmark report
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: benchmark-report
63+
path: benchmark-report
64+
if-no-files-found: warn
7365

74-
- name: Compare with previous benchmarks
75-
if: github.event_name == 'pull_request'
76-
run: |
77-
git fetch origin ${{ github.base_ref }}
78-
git checkout FETCH_HEAD
79-
cargo criterion --baseline main
80-
git checkout ${{ github.sha }}
81-
cargo criterion --baseline main
66+
- name: Compare with previous benchmarks
67+
if: github.event_name == 'pull_request'
68+
run: |
69+
git fetch origin ${{ github.base_ref }}
70+
git checkout FETCH_HEAD
71+
cargo criterion --baseline main
72+
git checkout ${{ github.sha }}
73+
cargo criterion --baseline main
8274
working-directory: .

0 commit comments

Comments
 (0)