Skip to content

Use upstream stlrs crate #30

Use upstream stlrs crate

Use upstream stlrs crate #30

Workflow file for this run

name: Benchmarks
on:
issue_comment:
types:
- created
permissions:
contents: read
pull-requests: write
env:
CARGO_TERM_COLOR: always
jobs:
"iai-benchmark":
runs-on: ubuntu-latest
name: Iai benchmarks
# Only run when organisation members comment on a PR with `/ci benchmark`
if: |
github.event.issue.pull_request && contains(github.event.comment.body, '/ci benchmark')
steps:
- name: Set up valgrind for iai
run: |
sudo apt update && sudo apt install -y valgrind
- name: Checkout main
uses: actions/checkout@v4
with:
ref: main
- uses: actions/cache@v3
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 bench against baseline bench
run: |
cargo bench --bench "*iai*" | tee iai_baseline
readlink -f iai_baseline
- name: Checkout PR
uses: actions/checkout@v4
with:
clean: false
- name: Run bench against current branch
run: cargo bench --bench "*iai*" | tee iai_feature
- name: Write result in PR
uses: actions/github-script@v6
with:
script: |
const { GITHUB_WORKSPACE } = process.env;
const fs = require('fs');
const iai_baseline = fs.readFileSync(`${GITHUB_WORKSPACE}/iai_baseline`, {encoding:'utf8', flag:'r'});
const iai_feature = fs.readFileSync(`${GITHUB_WORKSPACE}/iai_feature`, {encoding:'utf8', flag:'r'});
// form message
const quote = "```";
const message = '## Benchmarks\n---\n Current:\n```\n' + iai_feature + '\n```\n Previous:\n\n```\n' + iai_baseline + '\n```';
// post comment
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
})