Skip to content

黒魔術は濫用してなんぼ #11

黒魔術は濫用してなんぼ

黒魔術は濫用してなんぼ #11

Workflow file for this run

name: Benchmark
on:
push:
branches:
- main
paths:
- 'src/**'
- 'benchmark/**'
pull_request:
branches:
- main
paths:
- 'src/**'
- 'benchmark/**'
workflow_dispatch:
permissions:
contents: write
jobs:
benchmark:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
- name: Install dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y cmake wget
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 22
sudo apt-get update
wget https://github.com/sharkdp/hyperfine/releases/download/v1.20.0/hyperfine_1.20.0_amd64.deb
sudo dpkg -i hyperfine_1.20.0_amd64.deb
- name: Select LLVM 22
run: |
echo "CC=clang-22" >> "$GITHUB_ENV"
echo "CXX=clang++-22" >> "$GITHUB_ENV"
echo "AR=llvm-ar-22" >> "$GITHUB_ENV"
echo "NM=llvm-nm-22" >> "$GITHUB_ENV"
echo "RANLIB=llvm-ranlib-22" >> "$GITHUB_ENV"
echo "/usr/lib/llvm-22/bin" >> "$GITHUB_PATH"
- name: Verify LLVM 22
run: |
clang-22 --version
llvm-config-22 --version
- name: Build
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
clang ./benchmark/bf.c -o build/simple_c -O3
- name: Run benchmarks
run: |
set -euo pipefail
result_file="$(mktemp)"
block_file="$(mktemp)"
tmp_readme="$(mktemp)"
trap 'rm -f "$result_file" "$block_file" "$tmp_readme"' EXIT
hyperfine -w 1 -r 10 -N \
"./build/bfjit ./examples/hanoi.b.txt" \
"./build/simple_c ./examples/hanoi.b.txt" \
"bun ./benchmark/bf.js ./examples/hanoi.b.txt" \
| tee "$result_file"
{
printf '```text\n'
cat "$result_file"
printf '```\n'
} > "$block_file"
sed '/<!-- benchmark:start -->/,/<!-- benchmark:end -->/{//!d;}' README.md \
| sed "/<!-- benchmark:start -->/r $block_file" \
> "$tmp_readme"
mv "$tmp_readme" README.md
- name: Commit and push README update
if: github.event_name != 'pull_request'
run: |
set -euo pipefail
if git diff --quiet -- README.md; then
echo "README.md is unchanged"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add README.md
git commit -m "update benchmark results"
git push