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
report, mcp: use calibrated scan baseline in report and status_json in fast_status
Brixton Pham7272cb68ce08
diff --git a/src/mcp.rs b/src/mcp.rsindex 68e8b93..c2fe3d7 100644--- a/src/mcp.rs+++ b/src/mcp.rs@@ -121,7 +121,7 @@ fn call(params: &Value) -> Result<Value> {"fast_report" => serde_json::to_value(pipeline::report(&root, false)?)?,"fast_status" => {let ctx = state::Ctx::open(&root)?;- json!({ "command": ctx.state.command, "ports": ctx.state.ports, "bench": ctx.state.bench })+ crate::show::status_json(&ctx)}other => anyhow::bail!("unknown tool {other}"),})@@ -216,6 +216,21 @@ mod tests {assert!(handle(&json!({ "jsonrpc": "2.0", "method": "notifications/initialized" })).is_none());let bad = handle(&json!({ "jsonrpc": "2.0", "id": 3, "method": "nope" })).unwrap();assert_eq!(bad["error"]["code"], -32601);++ let dir = std::env::temp_dir().join(format!("fa-mcp-status-{}", std::process::id()));+ let _ = std::fs::remove_dir_all(&dir);+ std::fs::create_dir_all(dir.join(".fast")).unwrap();+ std::fs::write(+ dir.join(".fast/state.json"),+ r#"{"version": 1, "command": ["python", "app.py"], "lang": "python", "wall": 4.0, "unprofiled": 1.0}"#,+ )+ .unwrap();+ let status = call(&json!({ "name": "fast_status", "arguments": { "path": dir } })).unwrap();+ let _ = std::fs::remove_dir_all(&dir);+ assert_eq!(+ (&status["lang"], &status["wall_seconds"], &status["unprofiled_seconds"]),+ (&json!("python"), &json!(4.0), &json!(1.0))+ );}#[test]diff --git a/src/report.rs b/src/report.rsindex b444d1c..be20fd3 100644--- a/src/report.rs+++ b/src/report.rs@@ -129,16 +129,18 @@ fn scan_section(s: &State, b: &BenchResult) -> String {s.command.join(" "),secs(s.wall));- let (wall, original) = (s.wall, b.before.median);+ let (wall, original) = (s.wall, s.unprofiled.filter(|&u| u > 0.0).unwrap_or(b.before.median));+ let baseline =+ if s.unprofiled.is_some_and(|u| u > 0.0) { "when calibrated" } else { "the original's median above" };if wall > 0.0 && original > 0.0 {md.push_str(&if wall >= original {format!(- " against **{}** without it (the original's median above): profiling made it run {} as long",+ " against **{}** without it ({baseline}): profiling made it run {} as long",secs(original),times(wall / original))} else {- format!(", less than the original's **{}** median above: the scan was likely stopped early", secs(original))+ format!(", less than the **{}** without it ({baseline}): the scan was likely stopped early", secs(original))});}md.push_str(@@ -497,7 +499,17 @@ mod tests {let stopped_early = State { wall: 2.0, ..s.clone() };let md = markdown("app", &b, &stopped_early, &[]);- assert!(md.contains("less than the original's **4.00s** median above") && !md.contains("as long"), "{md}");+ assert!(+ md.contains("less than the **4.00s** without it (the original's median above)") && !md.contains("as long"),+ "{md}"+ );++ let calibrated = State { unprofiled: Some(3.1), ..s.clone() };+ let md = markdown("app", &b, &calibrated, &[]);+ assert!(+ md.contains("`python app.py`, which took **12.40s** under the profiler against **3.10s** without it (when calibrated): profiling made it run 4.0× as long."),+ "{md}"+ );let no_scan = State { hotspots: vec![], ..s };let md = markdown("app", &b, &no_scan, &[]);