Don't rewrite it in Rust. Rewrite the 5% that's slow: profile your app, port the hot functions with your coding agent, prove they behave the same. Python, JS/TS, Ruby, Java, Kotlin, Go, PHP, C/C++, C#, R.
Rust agent-skillsai-agentsclaude-codeclaude-code-plugincodexdeveloper-toolsffimcpmcp-servernapi-rsnodejsoptimizationperformanceprofilerpyo3pythonrewrite-it-in-rustrubyrusttypescript
bench refuses with no ports enabled, report says slower when slower, doctor exits 0 when it can scan (#142)
EL4CTEOf52ba235408f
diff --git a/src/backend.rs b/src/backend.rsindex ab6e5ab..e97085c 100644--- a/src/backend.rs+++ b/src/backend.rs@@ -430,7 +430,7 @@ pub fn build(ctx: &Ctx, port: &Port) -> Result<std::result::Result<PathBuf, Striif port.lang == Lang::Python {cmd.env("PYO3_PYTHON", exe);}- let out = output(&mut cmd, "cargo (install Rust from https://rustup.rs)")?;+ let out = output(&mut cmd, "cargo (install Rust from https://rustup.rs; scan works without it)")?;if !out.status.success() {return Ok(Err(compiler_errors(&String::from_utf8_lossy(&out.stderr))));}diff --git a/src/bench.rs b/src/bench.rsindex 1eb1b9f..a690ecd 100644--- a/src/bench.rs+++ b/src/bench.rs@@ -399,9 +399,10 @@ pub fn run(ctx: &Ctx, runs: usize) -> Result<BenchResult> {let (exe, args) = ctx.state.lang.bench_command(ctx)?;let (exe, args) = (exe.as_str(), args.as_slice());let ports: Vec<String> = ctx.state.ports.values().filter(|p| p.enabled).map(|p| p.id.clone()).collect();- if ports.is_empty() {- ui::warn("no ports are enabled yet, so before and after are the same code");- }+ ensure!(+ !ports.is_empty(),+ "no ports are enabled, so there is nothing to compare: port, verify and enable one first (fast-anything go)"+ );ui::step(format!("timing {} ({runs} rounds of {} twice and Rust once, rotated)",ui::bold(ctx.state.command.join(" ")),diff --git a/src/doctor.rs b/src/doctor.rsindex 354aebe..2218239 100644--- a/src/doctor.rs+++ b/src/doctor.rs@@ -168,8 +168,12 @@ pub fn run() -> Result<()> {"install Python, Node.js (or Bun, Deno), Ruby, Java, Go, PHP, .NET, R or a C compiler");ui::ok("ready to scan");- ensure!(usable(&checks[0]), "Rust 1.85 or newer is needed to port, verify and enable");- ui::ok("ready to port");+ // scanning works without Rust, so a missing toolchain only warns (#142)+ if usable(&checks[0]) {+ ui::ok("ready to port");+ } else {+ ui::warn("Rust 1.85 or newer is needed to port, verify and enable: https://rustup.rs");+ }Ok(())}diff --git a/src/report.rs b/src/report.rsindex 3a993f3..6f806fc 100644--- a/src/report.rs+++ b/src/report.rs@@ -27,8 +27,13 @@ fn port_line(p: &Port) -> String {}}+/// "8.0×" and "faster", or "1.1×" and "slower" when the app got slower (#142).+fn headline(speedup: f64) -> (String, &'static str) {+ if speedup >= 1.0 { (times(speedup), "faster") } else { (times(1.0 / speedup.max(1e-12)), "slower") }+}+pub fn svg(project: &str, b: &BenchResult, ports: &[&Port]) -> String {- let headline = times(b.speedup);+ let (headline, word) = headline(b.speedup);let after_w = (300.0 * b.after.median / b.before.median.max(1e-12)).clamp(4.0, 300.0);let mut detail = ports.iter().take(2).map(|p| port_line(p)).collect::<Vec<_>>().join(" ");// the card's detail line holds about 95 characters@@ -40,12 +45,12 @@ pub fn svg(project: &str, b: &BenchResult, ports: &[&Port]) -> String {let sans = "system-ui,-apple-system,Segoe UI,Helvetica,Arial,sans-serif";let mono = "ui-monospace,SFMono-Regular,Menlo,Consolas,monospace";format!(- r##"<svg xmlns="http://www.w3.org/2000/svg" width="760" height="220" viewBox="0 0 760 220" role="img" aria-label="{project}: {headline} faster">+ r##"<svg xmlns="http://www.w3.org/2000/svg" width="760" height="220" viewBox="0 0 760 220" role="img" aria-label="{project}: {headline} {word}"><rect width="760" height="220" rx="16" fill="#0d1117"/><rect x="0.5" y="0.5" width="759" height="219" rx="15.5" fill="none" stroke="#30363d"/><text x="32" y="44" font-family="{mono}" font-size="14" fill="#f74c00">⚡ fast-anything</text><text x="32" y="78" font-family="{sans}" font-size="20" fill="#e6edf3">{project}</text>- <text x="32" y="148" font-family="{sans}" font-size="64" font-weight="800" fill="#f74c00">{headline}<tspan dx="12" font-size="28" font-weight="600" fill="#e6edf3">faster</tspan></text>+ <text x="32" y="148" font-family="{sans}" font-size="64" font-weight="800" fill="#f74c00">{headline}<tspan dx="12" font-size="28" font-weight="600" fill="#e6edf3">{word}</tspan></text><text x="420" y="92" font-family="{sans}" font-size="13" fill="#8b949e">{original}</text><text x="720" y="92" font-family="{mono}" font-size="13" fill="#e6edf3" text-anchor="end">{before}</text><rect x="420" y="100" width="300" height="16" rx="4" fill="#30363d"/>@@ -75,9 +80,9 @@ pub fn markdown(project: &str, b: &BenchResult, ports: &[&Port]) -> String {} else {format!("median of {} runs each, original and Rust interleaved", b.runs)};+ let (head, word) = headline(b.speedup);let mut md = format!(- "# ⚡ {project}: {} faster\n\n`{}` went from **{}** to **{}** ({how}).\n\n",- times(b.speedup),+ "# ⚡ {project}: {head} {word}\n\n`{}` went from **{}** to **{}** ({how}).\n\n",b.command.join(" "),secs(b.before.median),secs(b.after.median),@@ -144,6 +149,19 @@ mod tests {assert!(card.contains(r#"width="37.5""#));}+ #[test]+ fn a_slower_app_is_called_slower() {+ let b = BenchResult {+ before: Stats { median: 8.42, ..Stats::default() },+ after: Stats { median: 9.27, ..Stats::default() },+ speedup: 8.42 / 9.27,+ ..BenchResult::default()+ };+ let (md, card) = (markdown("app", &b, &[]), svg("app", &b, &[]));+ assert!(md.starts_with("# ⚡ app: 1.1× slower"), "{md}");+ assert!(card.contains(">slower</tspan>") && !card.contains("faster"), "{card}");+ }+#[test]fn report_shows_cpu_time_and_the_aa_control() {let b = BenchResult {