Rewrite your app in Rust, piece by piece, checked against the original at every step. Works with TypeScript, JavaScript, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, PowerShell and Swift.
Rust agent-skillsclaude-codeclicode-migrationcodexffigolangjavajavascriptmcpmigrationnapiperformanceportingpyo3pythonrewriterubyrusttypescript
fix(profile): align C workload refusal message and name macOS Instruments profiler (#1430)
m3lon5bf98eb0001d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8c7ab86e..6da4c401 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,6 +2,7 @@## Unreleased+- `profile` and `go` on a C repository say they do not run C workloads yet and name Instruments' Time Profiler on macOS alongside `perf record -g` on Linux, matching other unsupported languages (#1398 by @m3lonxd).- Python: `time.localtime()`, `time.gmtime()`, `time.strftime()`, `time.ctime()`,`time.asctime()` and `datetime.today()` count as reading the clock in `bridge` and `analyze`.`analyze` also counts `datetime.today()` after `from datetime import datetime`, which resolves todiff --git a/src/profile.rs b/src/profile.rsindex 95564399..a80b084c 100644--- a/src/profile.rs+++ b/src/profile.rs@@ -385,8 +385,8 @@ pub fn profile_for(),Lang::Ruby => no_waits(ruby(&root, command, work.path())?),Lang::C => bail!(- "`{caller}` runs TS/JS, Python, Go, Java and Ruby workloads; for C, use `perf record -g` \- and port the hot loops it shows"+ "`{caller}` does not run C workloads yet; use Instruments' Time Profiler on macOS or \+ `perf record -g` on Linux and port the hot loops it shows"),Lang::Php => bail!("`{caller}` does not run PHP workloads yet; use SPX or Xdebug's profiler and port the \diff --git a/tests/profile.rs b/tests/profile.rsindex bddfb0f8..c7834594 100644--- a/tests/profile.rs+++ b/tests/profile.rs@@ -395,3 +395,22 @@ fn profile_lang_php_still_names_the_profiler_to_use() {"{stderr}");}++#[test]+fn profile_lang_c_names_macos_and_linux_profilers() {+ let tmp = TempDir::new("profile-lang-c");+ let out = Command::new(env!("CARGO_BIN_EXE_rust-anything"))+ .arg("profile")+ .arg(tmp.path())+ .args(["--lang", "c", "--", "./main"])+ .output()+ .unwrap();+ assert!(!out.status.success());+ let stderr = String::from_utf8_lossy(&out.stderr);+ assert!(+ stderr.contains("`profile` does not run C workloads yet"),+ "{stderr}"+ );+ assert!(stderr.contains("Instruments"), "{stderr}");+ assert!(stderr.contains("perf record -g"), "{stderr}");+}diff --git a/tests/skill.rs b/tests/skill.rsindex 2b4c1221..fccae67d 100644--- a/tests/skill.rs+++ b/tests/skill.rs@@ -442,7 +442,7 @@ fn the_skill_names_every_language_profile_refuses() {.expect_err(&format!("{} should be refused", lang.name())).to_string();assert!(- err.contains("workloads"),+ err.contains("does not run"),"{}: not the language refusal: {err}",lang.name());diff --git a/website/pages/en/docs/concepts/analyze.md b/website/pages/en/docs/concepts/analyze.mdindex 51f8812f..56784dc2 100644--- a/website/pages/en/docs/concepts/analyze.md+++ b/website/pages/en/docs/concepts/analyze.md@@ -14,7 +14,7 @@ rust-anything profile <repo> -- node bench.mjs # or: python3 bench.py, ruby# java -cp out Main, go test -run X -bench . ./pkg```-`profile` runs a real workload under the language's profiler (node, cProfile, `go test` pprof, JFR, a Ruby tracer) and lists hot functions by inclusive time, their callers, and which loops to batch. It runs TS/JS, Python, Go, Java and Ruby workloads; Go profiles only through `go test`. For the others it stops and names the profiler to use instead: `perf record -g` for C, JFR (`jfr print --stack-depth 256`) for Kotlin, SPX or Xdebug's profiler for PHP, `dotnet-trace` for C#, `Measure-Command` for PowerShell (time one `pwsh` start first: when a tool starts a shell per command, start-up is the slow part), and Instruments' Time Profiler (or `perf record -g` on Linux) for Swift.+`profile` runs a real workload under the language's profiler (node, cProfile, `go test` pprof, JFR, a Ruby tracer) and lists hot functions by inclusive time, their callers, and which loops to batch. It runs TS/JS, Python, Go, Java and Ruby workloads; Go profiles only through `go test`. For the others it stops and names the profiler to use instead: Instruments' Time Profiler on macOS or `perf record -g` on Linux for C, JFR (`jfr print --stack-depth 256`) for Kotlin, SPX or Xdebug's profiler for PHP, `dotnet-trace` for C#, `Measure-Command` for PowerShell (time one `pwsh` start first: when a tool starts a shell per command, start-up is the slow part), and Instruments' Time Profiler (or `perf record -g` on Linux) for Swift.- A small function called once per item is **not** worth porting alone: one call into Rust costs more than its work, and JITs (V8, the JVM, Go) run it in nanoseconds. Port it together with its callers, or [batch it](/docs/concepts/batches). The advice line says which, with the exact command.- Code that is already compiled (numba `@njit`, Cython, `@jax.jit`) runs as machine code: a Rust port gains little speed. `profile` lists it under "Already compiled".