name: Benchmark
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 3 * * 0'
env:
CARGO_TERM_COLOR: always
jobs:
benchmark:
name: Performance Benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-bench-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-bench-
${{ runner.os }}-cargo-
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libsdl2-dev
- name: Run benchmark tests (performance tests)
run: |
echo "## Performance Test Results" > benchmark-results.md
echo "" >> benchmark-results.md
# Run tests in release mode for performance measurement
echo "### Default features performance" >> benchmark-results.md
time cargo test --release 2>&1 | grep "finished in" | tee -a benchmark-results.md
echo "" >> benchmark-results.md
echo "### All features performance" >> benchmark-results.md
time cargo test --all-features --release 2>&1 | grep "finished in" | tee -a benchmark-results.md
echo "" >> benchmark-results.md
echo "### Minimal features performance" >> benchmark-results.md
time cargo test --no-default-features --features "no_std,integer-math" --release 2>&1 | grep "finished in" | tee -a benchmark-results.md
- name: Upload benchmark results
uses: actions/upload-artifact@v4
if: always()
with:
name: benchmark-results
path: benchmark-results.md
memory-usage:
name: Memory Usage Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-memory-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-memory-
${{ runner.os }}-cargo-
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libsdl2-dev valgrind
- name: Analyze library size and dependencies
run: |
echo "## Library Size and Dependency Analysis" > memory-report.md
echo "" >> memory-report.md
# Build examples with different feature combinations to analyze memory usage
echo "### Default features - Example builds" >> memory-report.md
cargo build --release --examples
echo "Example binaries built successfully" >> memory-report.md
echo "" >> memory-report.md
echo "### Minimal embedded features (no_std + integer-math)" >> memory-report.md
echo "Feature set: no_std, integer-math, minimal-memory" >> memory-report.md
cargo check --release --no-default-features --features "no_std,integer-math,minimal-memory" 2>&1 | tee -a memory-report.md
echo "" >> memory-report.md
echo "### Balanced embedded features (no_std + fixed-point)" >> memory-report.md
echo "Feature set: no_std, fixed-point, basic-charts" >> memory-report.md
cargo check --release --no-default-features --features "no_std,fixed-point,basic-charts" 2>&1 | tee -a memory-report.md
echo "" >> memory-report.md
echo "### Full embedded features (no_std + floating-point)" >> memory-report.md
echo "Feature set: no_std, floating-point, scatter, gauge" >> memory-report.md
cargo check --release --no-default-features --features "no_std,floating-point,scatter,gauge" 2>&1 | tee -a memory-report.md
echo "" >> memory-report.md
echo "### Dependency analysis" >> memory-report.md
echo "Dependency tree for minimal configuration:" >> memory-report.md
cargo tree --no-default-features --features "no_std,integer-math,minimal-memory" >> memory-report.md
- name: Upload memory analysis
uses: actions/upload-artifact@v4
if: always()
with:
name: memory-analysis
path: memory-report.md
compile-time:
name: Compile Time Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-compile-time-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-compile-time-
${{ runner.os }}-cargo-
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libsdl2-dev
- name: Measure compile times
run: |
echo "## Compile Time Analysis" > compile-time-report.md
echo "" >> compile-time-report.md
# Clean build
cargo clean
# Measure compile time for different feature sets
echo "### Default features" >> compile-time-report.md
time cargo build --timings=html,json 2>&1 | tee -a compile-time-report.md
echo "" >> compile-time-report.md
cargo clean
echo "### Minimal embedded features" >> compile-time-report.md
time cargo build --no-default-features --features "no_std,integer-math,minimal-memory" --timings=html,json 2>&1 | tee -a compile-time-report.md
echo "" >> compile-time-report.md
cargo clean
echo "### All features" >> compile-time-report.md
time cargo build --all-features --timings=html,json 2>&1 | tee -a compile-time-report.md
- name: Upload compile time analysis
uses: actions/upload-artifact@v4
if: always()
with:
name: compile-time-analysis
path: |
compile-time-report.md
cargo-timing-*.html