Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.
TypeScript ai-agentsanthropicclaude-codeclicode-graphcodexcontext-engineeringcursordeveloper-toolsgeminiknowledge-graphllmmcpmcp-serveropen-sourceopenaitree-sitter
test: time the machine-speed workload on the wall clock
Shrish Dwivedi04d7da0d6e67
diff --git a/test/machine-speed.ts b/test/machine-speed.tsindex b7aeef01..c05cbe2c 100644--- a/test/machine-speed.ts+++ b/test/machine-speed.ts@@ -10,18 +10,18 @@* several runs, against what it took where the bars were set. It is never* below 1, capped at 10, and exactly 1 under TRAIL_PERF=1 (the strict run).* Not a test file itself.+ *+ * Timed with `performance.now()`, the clock the tests use, not+ * `process.cpuUsage()`: on Windows CPU time moves in steps of about 15.6 ms,+ * so a 5 ms run reads as 0, the best of seven is 0, and a runner five times+ * slower than the laptop got a factor of 1.*/-/** The workload's CPU ms where the bars were set: an Apple M-series laptop on Node 25 (Node 20 there takes about 7). */+/** The workload's ms where the bars were set: an Apple M-series laptop on Node 25 (Node 20 there takes about 7). */const REFERENCE_MS = 5;let cached: number | null = null;-function cpuMs(): number {- const u = process.cpuUsage();- return (u.user + u.system) / 1000;-}-function workload(): number {const text = "token=abc def-ghi /var/x?key=1 ".repeat(8 * 1024);let n = 0;@@ -32,14 +32,14 @@ function workload(): number {return n;}-/** The workload's best CPU ms here, after a warm-up run. */+/** The workload's best ms here, after a warm-up run. */export function workloadMs(): number {workload();let best = Infinity;for (let k = 0; k < 7; k++) {- const t = cpuMs();+ const t = performance.now();workload();- best = Math.min(best, cpuMs() - t);+ best = Math.min(best, performance.now() - t);}return best;}