Repository navigation
Handle moving average updates on candle revisions #358
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
| name: benchmark | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [main] | |
| permissions: write-all | |
| concurrency: | |
| group: benchmark-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| perf: | |
| if: ${{ github.actor == 'qqrm' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: dtolnay/rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| targets: wasm32-unknown-unknown | |
| - name: Cache cargo | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.x' | |
| - name: Install wasm-pack | |
| run: cargo install wasm-pack --version 0.13.1 | |
| - name: Run benchmarks | |
| env: | |
| WASM_BINDGEN_TEST_BROWSER_ARGS: "--no-sandbox --enable-unsafe-webgpu" | |
| run: | | |
| set -o pipefail | |
| wasm-pack test --chrome --headless | tee perf.log | |
| python scripts/parse_perf_log.py perf.log benchmark_result.json | |
| - name: Analyze FPS | |
| run: | | |
| python scripts/compare_fps.py benchmark_result.json docs/perf_baseline.json docs/perf_result.json 5 | |
| - name: Update perf markdown | |
| run: | | |
| python - <<'EOF' | |
| import json, pathlib | |
| data = json.load(open('docs/perf_result.json')) | |
| lines = ['# Latest metrics', '', '| Metric | Value |', '| --- | --- |'] | |
| for k, v in data.items(): | |
| lines.append(f'| {k} | {v} |') | |
| pathlib.Path('docs/perf.md').write_text('\n'.join(lines) + '\n') | |
| EOF | |
| - name: Commit results | |
| run: | | |
| git config user.name github-actions | |
| git config user.email github-actions@github.com | |
| git add docs/perf.md docs/perf_result.json docs/perf_baseline.json | |
| git commit -m "Update perf metrics" || echo "No changes" | |
| git push | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: perf_results | |
| path: docs/perf_result.json | |
| - name: Send benchmark results to bot | |
| env: | |
| TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | |
| TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} | |
| run: scripts/send_to_bot.sh docs/perf_result.json "Benchmark results" |