Skip to content

increased stability and effeciency of webcam system #9

increased stability and effeciency of webcam system

increased stability and effeciency of webcam system #9

Workflow file for this run

name: Benchmarks
# Story 7.2: AC7 - CI benchmark integration
# AC8 - Regression detection (>10% slowdown alerts)
on:
push:
branches:
- main
pull_request:
branches:
- main
# Cancel in-progress runs for the same branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
benchmark:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "benchmark"
# Run core benchmarks (no features required)
- name: Run core benchmarks
run: cargo bench --bench core_rendering --bench animation -- --noplot
# Run feature-gated benchmarks
- name: Run image processing benchmarks
run: cargo bench --bench image_processing --features image -- --noplot
# Run all registered benchmarks with all features
- name: Run all benchmarks (full suite)
run: cargo bench --all-features -- --noplot
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: criterion-results-${{ github.sha }}
path: target/criterion/
retention-days: 30
# Regression detection job (AC8)
regression-check:
runs-on: ubuntu-latest
needs: benchmark
if: github.event_name == 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "benchmark"
# Download baseline from main branch (if available)
- name: Download baseline results
uses: dawidd6/action-download-artifact@v3
with:
workflow: benchmark.yml
branch: main
name: criterion-results-*
path: target/criterion-baseline/
continue-on-error: true
# Run benchmarks for PR
- name: Run PR benchmarks
run: cargo bench --all-features -- --noplot --save-baseline pr-results
# Compare against baseline
- name: Check for regressions
id: regression
run: |
# If baseline exists, compare
if [ -d "target/criterion-baseline" ]; then
echo "Comparing against baseline..."
# Use criterion's comparison output
cargo bench --all-features -- --noplot --load-baseline pr-results 2>&1 | tee benchmark-comparison.txt
# Check for significant regressions (>10%)
if grep -q "Performance has regressed" benchmark-comparison.txt; then
echo "regression_detected=true" >> $GITHUB_OUTPUT
echo "## ⚠️ Performance Regression Detected" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
grep -A5 "Performance has regressed" benchmark-comparison.txt >> $GITHUB_STEP_SUMMARY
else
echo "regression_detected=false" >> $GITHUB_OUTPUT
echo "## ✅ No Performance Regressions" >> $GITHUB_STEP_SUMMARY
fi
else
echo "No baseline available for comparison"
echo "regression_detected=false" >> $GITHUB_OUTPUT
echo "## ℹ️ No Baseline Available" >> $GITHUB_STEP_SUMMARY
echo "First benchmark run - no regression check performed." >> $GITHUB_STEP_SUMMARY
fi
# Comment on PR if regression detected
- name: Comment on PR (regression warning)
if: steps.regression.outputs.regression_detected == 'true'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const comparison = fs.readFileSync('benchmark-comparison.txt', 'utf8');
// Find regression lines
const regressions = comparison.split('\n')
.filter(line => line.includes('regressed') || line.includes('Performance'))
.join('\n');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## ⚠️ Performance Regression Detected
Some benchmarks show >10% regression compared to main branch.
\`\`\`
${regressions.substring(0, 1000)}
\`\`\`
Please review the performance impact of your changes.
📊 Full benchmark results available in the [Actions artifacts](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}).
`
});