Skip to content

Commit dc4ac32

Browse files
committed
chore: M5 CI/Workflow Sweep - final synchronisation
1 parent e688718 commit dc4ac32

5 files changed

Lines changed: 149 additions & 149 deletions

File tree

src/abi/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ mod tests {
397397
let mut result = BenchmarkResult::new("test", SourceLanguage::Python);
398398
result.original_time_seconds = Some(10.0);
399399
result.julia_time_seconds = Some(0.1);
400-
let speedup = result.compute_speedup().unwrap();
400+
let speedup = result.compute_speedup().expect("TODO: handle error");
401401
assert!((speedup - 100.0).abs() < 0.001);
402402
}
403403

src/codegen/benchmark.rs

Lines changed: 96 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@ pub fn generate_benchmarks(
7979
fn generate_julia_benchmark(manifest: &Manifest, units: &[TranslationUnit]) -> String {
8080
let mut out = String::new();
8181

82-
writeln!(out, "# SPDX-License-Identifier: PMPL-1.0-or-later").unwrap();
83-
writeln!(out, "# Auto-generated by julianiser — benchmark script").unwrap();
84-
writeln!(out, "# Project: {}", manifest.project.name).unwrap();
85-
writeln!(out, "#").unwrap();
86-
writeln!(out, "# Run with: julia --project=. benchmarks/benchmark.jl").unwrap();
87-
writeln!(out).unwrap();
82+
writeln!(out, "# SPDX-License-Identifier: PMPL-1.0-or-later").expect("TODO: handle error");
83+
writeln!(out, "# Auto-generated by julianiser — benchmark script").expect("TODO: handle error");
84+
writeln!(out, "# Project: {}", manifest.project.name).expect("TODO: handle error");
85+
writeln!(out, "#").expect("TODO: handle error");
86+
writeln!(out, "# Run with: julia --project=. benchmarks/benchmark.jl").expect("TODO: handle error");
87+
writeln!(out).expect("TODO: handle error");
8888

89-
writeln!(out, "using BenchmarkTools").unwrap();
90-
writeln!(out, "using Printf").unwrap();
91-
writeln!(out).unwrap();
89+
writeln!(out, "using BenchmarkTools").expect("TODO: handle error");
90+
writeln!(out, "using Printf").expect("TODO: handle error");
91+
writeln!(out).expect("TODO: handle error");
9292

9393
// Include each generated module.
9494
for unit in units {
@@ -97,40 +97,40 @@ fn generate_julia_benchmark(manifest: &Manifest, units: &[TranslationUnit]) -> S
9797
"include(\"../{}\") # from {}",
9898
unit.output_path, unit.source_path
9999
)
100-
.unwrap();
101-
writeln!(out, "using .{}", unit.module_name).unwrap();
100+
.expect("TODO: handle error");
101+
writeln!(out, "using .{}", unit.module_name).expect("TODO: handle error");
102102
}
103-
writeln!(out).unwrap();
103+
writeln!(out).expect("TODO: handle error");
104104

105-
writeln!(out, "println(\"=\"^60)").unwrap();
105+
writeln!(out, "println(\"=\"^60)").expect("TODO: handle error");
106106
writeln!(
107107
out,
108108
"println(\"julianiser Benchmark: {}\") ",
109109
manifest.project.name
110110
)
111-
.unwrap();
112-
writeln!(out, "println(\"=\"^60)").unwrap();
113-
writeln!(out).unwrap();
111+
.expect("TODO: handle error");
112+
writeln!(out, "println(\"=\"^60)").expect("TODO: handle error");
113+
writeln!(out).expect("TODO: handle error");
114114

115-
writeln!(out, "# Warm up Julia's JIT compiler before benchmarking.").unwrap();
116-
writeln!(out, "println(\"Warming up JIT...\")").unwrap();
115+
writeln!(out, "# Warm up Julia's JIT compiler before benchmarking.").expect("TODO: handle error");
116+
writeln!(out, "println(\"Warming up JIT...\")").expect("TODO: handle error");
117117
for unit in units {
118-
writeln!(out, "try").unwrap();
119-
writeln!(out, " {}.run_pipeline()", unit.module_name).unwrap();
120-
writeln!(out, "catch e").unwrap();
118+
writeln!(out, "try").expect("TODO: handle error");
119+
writeln!(out, " {}.run_pipeline()", unit.module_name).expect("TODO: handle error");
120+
writeln!(out, "catch e").expect("TODO: handle error");
121121
writeln!(
122122
out,
123123
" @warn \"Warm-up failed for {}: $e\"",
124124
unit.module_name
125125
)
126-
.unwrap();
127-
writeln!(out, "end").unwrap();
126+
.expect("TODO: handle error");
127+
writeln!(out, "end").expect("TODO: handle error");
128128
}
129-
writeln!(out).unwrap();
129+
writeln!(out).expect("TODO: handle error");
130130

131-
writeln!(out, "println(\"\\nRunning benchmarks...\")").unwrap();
132-
writeln!(out, "println(\"-\"^60)").unwrap();
133-
writeln!(out).unwrap();
131+
writeln!(out, "println(\"\\nRunning benchmarks...\")").expect("TODO: handle error");
132+
writeln!(out, "println(\"-\"^60)").expect("TODO: handle error");
133+
writeln!(out).expect("TODO: handle error");
134134

135135
// Benchmark each module.
136136
for unit in units {
@@ -139,32 +139,32 @@ fn generate_julia_benchmark(manifest: &Manifest, units: &[TranslationUnit]) -> S
139139
"println(\"\\nBenchmark: {} (from {})\") ",
140140
unit.module_name, unit.source_path
141141
)
142-
.unwrap();
142+
.expect("TODO: handle error");
143143
writeln!(
144144
out,
145145
"bench_{} = @benchmark {}.run_pipeline()",
146146
to_snake(&unit.module_name),
147147
unit.module_name
148148
)
149-
.unwrap();
150-
writeln!(out, "display(bench_{})", to_snake(&unit.module_name)).unwrap();
151-
writeln!(out, "println()").unwrap();
152-
writeln!(out).unwrap();
149+
.expect("TODO: handle error");
150+
writeln!(out, "display(bench_{})", to_snake(&unit.module_name)).expect("TODO: handle error");
151+
writeln!(out, "println()").expect("TODO: handle error");
152+
writeln!(out).expect("TODO: handle error");
153153
}
154154

155155
// Summary.
156-
writeln!(out, "println(\"=\"^60)").unwrap();
157-
writeln!(out, "println(\"Summary\")").unwrap();
158-
writeln!(out, "println(\"=\"^60)").unwrap();
156+
writeln!(out, "println(\"=\"^60)").expect("TODO: handle error");
157+
writeln!(out, "println(\"Summary\")").expect("TODO: handle error");
158+
writeln!(out, "println(\"=\"^60)").expect("TODO: handle error");
159159
for unit in units {
160160
let snake = to_snake(&unit.module_name);
161161
writeln!(
162162
out,
163163
"@printf(\" {}: median = %.3f ms, allocs = %d\\n\", median(bench_{}).time / 1e6, bench_{}.allocs)",
164164
unit.module_name, snake, snake
165-
).unwrap();
165+
).expect("TODO: handle error");
166166
}
167-
writeln!(out).unwrap();
167+
writeln!(out).expect("TODO: handle error");
168168
writeln!(
169169
out,
170170
"println(\"\\nCompare these with your original {} timings.\") ",
@@ -173,12 +173,12 @@ fn generate_julia_benchmark(manifest: &Manifest, units: &[TranslationUnit]) -> S
173173
.map(|u| u.language.to_string())
174174
.unwrap_or_default()
175175
)
176-
.unwrap();
176+
.expect("TODO: handle error");
177177
writeln!(
178178
out,
179179
"println(\"Julia's JIT typically delivers 10-100x speedup on array/DataFrame operations.\")"
180180
)
181-
.unwrap();
181+
.expect("TODO: handle error");
182182

183183
out
184184
}
@@ -193,133 +193,133 @@ fn generate_julia_benchmark(manifest: &Manifest, units: &[TranslationUnit]) -> S
193193
fn generate_benchmark_runner(manifest: &Manifest, units: &[TranslationUnit]) -> String {
194194
let mut out = String::new();
195195

196-
writeln!(out, "#!/usr/bin/env bash").unwrap();
197-
writeln!(out, "# SPDX-License-Identifier: PMPL-1.0-or-later").unwrap();
198-
writeln!(out, "# Auto-generated by julianiser — benchmark runner").unwrap();
199-
writeln!(out, "# Project: {}", manifest.project.name).unwrap();
200-
writeln!(out, "set -euo pipefail").unwrap();
201-
writeln!(out).unwrap();
196+
writeln!(out, "#!/usr/bin/env bash").expect("TODO: handle error");
197+
writeln!(out, "# SPDX-License-Identifier: PMPL-1.0-or-later").expect("TODO: handle error");
198+
writeln!(out, "# Auto-generated by julianiser — benchmark runner").expect("TODO: handle error");
199+
writeln!(out, "# Project: {}", manifest.project.name).expect("TODO: handle error");
200+
writeln!(out, "set -euo pipefail").expect("TODO: handle error");
201+
writeln!(out).expect("TODO: handle error");
202202

203203
writeln!(
204204
out,
205205
"SCRIPT_DIR=\"$(cd \"$(dirname \"${{BASH_SOURCE[0]}}\")\" && pwd)\""
206206
)
207-
.unwrap();
208-
writeln!(out, "PROJECT_DIR=\"$(dirname \"$SCRIPT_DIR\")\"").unwrap();
209-
writeln!(out).unwrap();
207+
.expect("TODO: handle error");
208+
writeln!(out, "PROJECT_DIR=\"$(dirname \"$SCRIPT_DIR\")\"").expect("TODO: handle error");
209+
writeln!(out).expect("TODO: handle error");
210210

211211
writeln!(
212212
out,
213213
"echo \"============================================================\""
214214
)
215-
.unwrap();
215+
.expect("TODO: handle error");
216216
writeln!(
217217
out,
218218
"echo \"julianiser Benchmark Runner: {}\"",
219219
manifest.project.name
220220
)
221-
.unwrap();
221+
.expect("TODO: handle error");
222222
writeln!(
223223
out,
224224
"echo \"============================================================\""
225225
)
226-
.unwrap();
227-
writeln!(out).unwrap();
226+
.expect("TODO: handle error");
227+
writeln!(out).expect("TODO: handle error");
228228

229229
// Run original source files.
230230
for unit in units {
231-
writeln!(out, "echo \"\"").unwrap();
231+
writeln!(out, "echo \"\"").expect("TODO: handle error");
232232
writeln!(
233233
out,
234234
"echo \"--- Original: {} ({}) ---\"",
235235
unit.source_path, unit.language
236236
)
237-
.unwrap();
237+
.expect("TODO: handle error");
238238

239239
match unit.language {
240240
SourceLanguage::Python => {
241-
writeln!(out, "if command -v python3 &> /dev/null; then").unwrap();
242-
writeln!(out, " echo \"Timing: python3 {}\"", unit.source_path).unwrap();
241+
writeln!(out, "if command -v python3 &> /dev/null; then").expect("TODO: handle error");
242+
writeln!(out, " echo \"Timing: python3 {}\"", unit.source_path).expect("TODO: handle error");
243243
writeln!(
244244
out,
245245
" time python3 \"$PROJECT_DIR/../{}\" 2>&1 || echo \" (Python script failed or not found)\"",
246246
unit.source_path
247247
)
248-
.unwrap();
249-
writeln!(out, "else").unwrap();
248+
.expect("TODO: handle error");
249+
writeln!(out, "else").expect("TODO: handle error");
250250
writeln!(
251251
out,
252252
" echo \" python3 not found — skipping original benchmark\""
253253
)
254-
.unwrap();
255-
writeln!(out, "fi").unwrap();
254+
.expect("TODO: handle error");
255+
writeln!(out, "fi").expect("TODO: handle error");
256256
}
257257
SourceLanguage::R => {
258-
writeln!(out, "if command -v Rscript &> /dev/null; then").unwrap();
259-
writeln!(out, " echo \"Timing: Rscript {}\"", unit.source_path).unwrap();
258+
writeln!(out, "if command -v Rscript &> /dev/null; then").expect("TODO: handle error");
259+
writeln!(out, " echo \"Timing: Rscript {}\"", unit.source_path).expect("TODO: handle error");
260260
writeln!(
261261
out,
262262
" time Rscript \"$PROJECT_DIR/../{}\" 2>&1 || echo \" (R script failed or not found)\"",
263263
unit.source_path
264264
)
265-
.unwrap();
266-
writeln!(out, "else").unwrap();
265+
.expect("TODO: handle error");
266+
writeln!(out, "else").expect("TODO: handle error");
267267
writeln!(
268268
out,
269269
" echo \" Rscript not found — skipping original benchmark\""
270270
)
271-
.unwrap();
272-
writeln!(out, "fi").unwrap();
271+
.expect("TODO: handle error");
272+
writeln!(out, "fi").expect("TODO: handle error");
273273
}
274274
}
275275
}
276276

277-
writeln!(out).unwrap();
278-
writeln!(out, "echo \"\"").unwrap();
279-
writeln!(out, "echo \"--- Julia (generated) ---\"").unwrap();
280-
writeln!(out, "if command -v julia &> /dev/null; then").unwrap();
277+
writeln!(out).expect("TODO: handle error");
278+
writeln!(out, "echo \"\"").expect("TODO: handle error");
279+
writeln!(out, "echo \"--- Julia (generated) ---\"").expect("TODO: handle error");
280+
writeln!(out, "if command -v julia &> /dev/null; then").expect("TODO: handle error");
281281
writeln!(
282282
out,
283283
" echo \"Running Julia benchmark (includes JIT compilation)...\""
284284
)
285-
.unwrap();
285+
.expect("TODO: handle error");
286286
writeln!(
287287
out,
288288
" time julia --project=\"$PROJECT_DIR\" \"$SCRIPT_DIR/benchmark.jl\" 2>&1"
289289
)
290-
.unwrap();
291-
writeln!(out, "else").unwrap();
290+
.expect("TODO: handle error");
291+
writeln!(out, "else").expect("TODO: handle error");
292292
writeln!(
293293
out,
294294
" echo \" julia not found — install Julia >= {} to run benchmarks\"",
295295
manifest.julia.version
296296
)
297-
.unwrap();
298-
writeln!(out, "fi").unwrap();
299-
writeln!(out).unwrap();
297+
.expect("TODO: handle error");
298+
writeln!(out, "fi").expect("TODO: handle error");
299+
writeln!(out).expect("TODO: handle error");
300300

301-
writeln!(out, "echo \"\"").unwrap();
301+
writeln!(out, "echo \"\"").expect("TODO: handle error");
302302
writeln!(
303303
out,
304304
"echo \"============================================================\""
305305
)
306-
.unwrap();
307-
writeln!(out, "echo \"Benchmark complete.\"").unwrap();
306+
.expect("TODO: handle error");
307+
writeln!(out, "echo \"Benchmark complete.\"").expect("TODO: handle error");
308308
writeln!(
309309
out,
310310
"echo \"For accurate Julia timings, run benchmark.jl directly\""
311311
)
312-
.unwrap();
312+
.expect("TODO: handle error");
313313
writeln!(
314314
out,
315315
"echo \"(the first run includes precompilation overhead).\""
316316
)
317-
.unwrap();
317+
.expect("TODO: handle error");
318318
writeln!(
319319
out,
320320
"echo \"============================================================\""
321321
)
322-
.unwrap();
322+
.expect("TODO: handle error");
323323

324324
out
325325
}
@@ -332,30 +332,30 @@ fn generate_benchmark_runner(manifest: &Manifest, units: &[TranslationUnit]) ->
332332
fn generate_results_template(units: &[TranslationUnit]) -> String {
333333
let mut out = String::new();
334334

335-
writeln!(out, "# SPDX-License-Identifier: PMPL-1.0-or-later").unwrap();
336-
writeln!(out, "# julianiser benchmark results").unwrap();
335+
writeln!(out, "# SPDX-License-Identifier: PMPL-1.0-or-later").expect("TODO: handle error");
336+
writeln!(out, "# julianiser benchmark results").expect("TODO: handle error");
337337
writeln!(
338338
out,
339339
"# Fill in timing data after running benchmark_runner.sh"
340340
)
341-
.unwrap();
342-
writeln!(out).unwrap();
341+
.expect("TODO: handle error");
342+
writeln!(out).expect("TODO: handle error");
343343

344344
for unit in units {
345-
writeln!(out, "[[benchmarks]]").unwrap();
346-
writeln!(out, "name = \"{}\"", unit.module_name).unwrap();
347-
writeln!(out, "source = \"{}\"", unit.source_path).unwrap();
348-
writeln!(out, "language = \"{}\"", unit.language).unwrap();
349-
writeln!(out, "original_time_seconds = 0.0 # TODO: fill in").unwrap();
350-
writeln!(out, "julia_time_seconds = 0.0 # TODO: fill in").unwrap();
345+
writeln!(out, "[[benchmarks]]").expect("TODO: handle error");
346+
writeln!(out, "name = \"{}\"", unit.module_name).expect("TODO: handle error");
347+
writeln!(out, "source = \"{}\"", unit.source_path).expect("TODO: handle error");
348+
writeln!(out, "language = \"{}\"", unit.language).expect("TODO: handle error");
349+
writeln!(out, "original_time_seconds = 0.0 # TODO: fill in").expect("TODO: handle error");
350+
writeln!(out, "julia_time_seconds = 0.0 # TODO: fill in").expect("TODO: handle error");
351351
writeln!(
352352
out,
353353
"speedup = 0.0 # TODO: compute original / julia"
354354
)
355-
.unwrap();
356-
writeln!(out, "iterations = 1000").unwrap();
357-
writeln!(out, "notes = \"\"").unwrap();
358-
writeln!(out).unwrap();
355+
.expect("TODO: handle error");
356+
writeln!(out, "iterations = 1000").expect("TODO: handle error");
357+
writeln!(out, "notes = \"\"").expect("TODO: handle error");
358+
writeln!(out).expect("TODO: handle error");
359359
}
360360

361361
out

0 commit comments

Comments
 (0)