Skip to content

Update microbiorust-py_benchmarks.yml #71

Update microbiorust-py_benchmarks.yml

Update microbiorust-py_benchmarks.yml #71

name: Run Benchmarks
on:
push:
branches:
- main
permissions:
contents: write
pages: write
id-token: write
jobs:
benchmark:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: pip install asv virtualenv maturin biopython
# 1. GET OLD HISTORY
- name: Load previous results
continue-on-error: true
uses: actions/checkout@v4
with:
ref: gh-pages
path: old_pages
# set up ASV here so as to copy the history to it
- name: Configure ASV
working-directory: microbiorust-py
run: asv machine --machine "github-runner" --yes
# 2. PUT HISTORY
- name: Restore results
run: |
#there were difficulties with a subfolder being created sometimes
ASV_ROOT_RESULTS_DIR="microbiorust-py/.asv/results/"
ASV_MACHINE_RESULTS_DIR="microbiorust-py/.asv/results/github-runner/"
if [ -d "old_pages/results" ]; then
echo "Restoring previous benchmark results from old_pages/results..."
mkdir -p "${ASV_ROOT_RESULTS_DIR}"
rsync -av old_pages/results/ "${ASV_ROOT_RESULTS_DIR}"
else
echo "No previous results found. Starting fresh."
fi
if [ -d "old_pages/results/github-runner/" ]; then
echo "restoring results from old_pages/results/github-runner"
mkdir -p "${ASV_MACHINE_RESULTS_DIR}"
rsync -av old_pages/results/github-runner/ "${ASV_MACHINE_RESULTS_DIR}"
else
echo "No machine specific results found"
fi
# 3. ADD NEW DATA POINT
- name: Run Benchmarks
working-directory: microbiorust-py
env:
MATURIN_PY_BUILD_ARGS: "--release"
RUSTFLAGS: "-C target-cpu=native"
run: asv run HEAD^! --machine "github-runner" --show-stderr
# Measure Rust energy use:
- name: Start Rust Energy measurement
uses: green-coding-solutions/eco-ci-energy-estimation@v4
with:
task: start-measurement
- name: Run Rust benchmarks for energy
working-directory: microbiorust-py
env:
MATURIN_PY_BUILD_ARGS: "--release"
RUSTFLAGS: "-C target-cpu=native"
run: |
asv run HEAD^! --machine "github-runner" --bench "PipelineSuite.time_process-all.*rust.*interactive" --show-stderr
- name: Record Rust Energy use
uses: green-coding-solutions/eco-ci-energy-estimation@v4
with:
task: get-measurement
output-file: eco-ci-rust.json
label: 'Rust Implementation'
- name: Start Python energy measurement
uses: green-coding-solutions/eco-ci-energy-estimation@v4
with:
task: start-measurement
- name: Run python benchmarks (for energy estimation)
working-directory: microbiorust-py
env:
MATURIN_PY_BUILD_ARGS: "--release"
RUSTFLAGS: "-C target-cpu=native"
run: |
asv run HEAD^! --machine "github-runner" --bench "PipelineSuite.time_process-all.*python.*interactive" --show-stderr
- name: Record Python energy
uses: green-coding-solutions/eco-ci-energy-estimation@v4
with:
task: get-measurement
output-file: eco-ci-python.json
label: 'Python Implementation'
- name: Display energy comparison
uses: green-coding-solutions/eco-ci-energy-estimation@v4
with:
task: display-results
# 4. GENERATE WEBSITE
- name: Generate HTML
working-directory: microbiorust-py
run: asv publish
# 5. PACK NEW HISTORY INTO THE WEBSITE FOLDER (Crucial Step!)
- name: Save results for next time
run: |
# Make sure the destination exists inside the HTML folder
mkdir -p microbiorust-py/.asv/html/results/
# Copy the accumulated JSON files (Old + New) into the publish dir
rsync -av microbiorust-py/.asv/results/ microbiorust-py/.asv/html/results/
# 6. UPLOAD EVERYTHING
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: microbiorust-py/.asv/html
publish_branch: gh-pages