Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 79f4cc0

Browse files
committed
Run y.rs bench in CI
1 parent d1024b6 commit 79f4cc0

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

.github/workflows/main.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,45 @@ jobs:
185185
env:
186186
TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
187187
run: ./y.rs abi-cafe
188+
189+
bench:
190+
runs-on: ubuntu-latest
191+
timeout-minutes: 60
192+
193+
defaults:
194+
run:
195+
shell: bash
196+
197+
steps:
198+
- uses: actions/checkout@v3
199+
200+
- name: Cache cargo target dir
201+
uses: actions/cache@v3
202+
with:
203+
path: build/cg_clif
204+
key: ${{ runner.os }}-x86_64-unknown-linux-gnu-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
205+
206+
- name: Cache cargo bin dir
207+
uses: actions/cache@v3
208+
with:
209+
path: ~/.cargo/bin
210+
key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-bin-dir-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
211+
212+
- name: Use sparse cargo registry
213+
run: |
214+
cat >> ~/.cargo/config.toml <<EOF
215+
[unstable]
216+
sparse-registry = true
217+
EOF
218+
219+
- name: Install hyperfine
220+
run: cargo install hyperfine
221+
222+
- name: Prepare dependencies
223+
run: ./y.rs prepare
224+
225+
- name: Build
226+
run: ./y.rs build --sysroot none
227+
228+
- name: Benchmark
229+
run: ./y.rs bench

build_system/bench.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::path::Path;
55
use super::path::{Dirs, RelPath};
66
use super::prepare::GitRepo;
77
use super::rustc_info::get_file_name;
8-
use super::utils::{hyperfine_command, is_ci, spawn_and_wait, CargoProject, Compiler};
8+
use super::utils::{hyperfine_command, spawn_and_wait, CargoProject, Compiler};
99

1010
static SIMPLE_RAYTRACER_REPO: GitRepo = GitRepo::github(
1111
"ebobby",
@@ -54,10 +54,7 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
5454
)
5555
.unwrap();
5656

57-
let run_runs = env::var("RUN_RUNS")
58-
.unwrap_or(if is_ci() { "2" } else { "10" }.to_string())
59-
.parse()
60-
.unwrap();
57+
let bench_runs = env::var("BENCH_RUNS").unwrap_or_else(|_| "10".to_string()).parse().unwrap();
6158

6259
eprintln!("[BENCH COMPILE] ebobby/simple-raytracer");
6360
let cargo_clif =
@@ -83,7 +80,7 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
8380
);
8481

8582
let bench_compile =
86-
hyperfine_command(1, run_runs, Some(&clean_cmd), &llvm_build_cmd, &clif_build_cmd);
83+
hyperfine_command(1, bench_runs, Some(&clean_cmd), &llvm_build_cmd, &clif_build_cmd);
8784

8885
spawn_and_wait(bench_compile);
8986

@@ -96,7 +93,7 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
9693

9794
let mut bench_run = hyperfine_command(
9895
0,
99-
run_runs,
96+
bench_runs,
10097
None,
10198
Path::new(".").join(get_file_name("raytracer_cg_llvm", "bin")).to_str().unwrap(),
10299
Path::new(".").join(get_file_name("raytracer_cg_clif", "bin")).to_str().unwrap(),

0 commit comments

Comments
 (0)