name: Benchmarks
on:
pull_request:
permissions:
contents: write
jobs:
iai_benchmark:
runs-on: ubuntu-latest
name: IAI Benchmarks
steps:
- name: Checkout main
uses: actions/checkout@v3
with:
ref: main
- uses: actions/cache@v1
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db/
./target/release
key: "${{ runner.os }}-cargo-build-stable-${{ hashFiles('**/Cargo.lock') }}"
- name: Run baseline bench
run: cargo bench --bench "*iai*"
- name: "Upload Artifact"
uses: actions/upload-artifact@v3
with:
name: baseline
path: ./target/iai
- name: Checkout PR
uses: actions/checkout@v3
- name: Download a single artifact
uses: actions/download-artifact@v3
with:
name: baseline
path: ./target/iai
- name: Run bench against baseline
run: cargo bench --bench "*iai*" > iai_feature
- name: Write result in PR
uses: actions/github-script@v5
with:
script: |
const fs = require('fs');
// read the output file
// const criterion_result = fs.readFileSync("bench_result", {encoding:'utf8', flag:'r'});
// const iai_baseline = fs.readFileSync("iai_baseline", {encoding:'utf8', flag:'r'});
const iai_feature = fs.readFileSync("iai_feature", {encoding:'utf8', flag:'r'});
// form message
const quote = "```";
const message = `👋\n\niai changes:\n ${quote}txt\n${iai_feature}${quote}`;
// post comment
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
})