| name | debug-performance |
|---|---|
| description | Improve performance in Codex by measuring baseline behavior, isolating hot paths, implementing focused optimizations, and confirming wins with before/after numbers. |
| compatibility | Codex CLI with terminal access, git, tokenlean CLI (npm i -g tokenlean) |
Measure first. Optimize second.
Measure -> Isolate -> Analyze -> Optimize -> Confirm
tl run "time <command>" # Capture baseline with token-efficient outputCapture baseline metrics (latency, throughput, memory) before edits.
tl parallel \
"symbols=tl symbols <suspect-file>" \
"complexity=tl complexity <suspect-file>" \
"hotspots=tl hotspots"Prioritize hot paths and repeated work.
tl parallel \
"snippet=tl snippet <function> <file>" \
"flow=tl flow <function> <file>" \
"deps=tl deps <file>"Check for:
- N^2 loops
- Repeated expensive I/O
- Heavy initialization on hot paths
- Work that can be cached or deferred
- Use the smallest optimization with clear impact.
- Preserve behavior and API.
- Prefer algorithmic improvements over micro-optimizations.
tl parallel "after=tl run 'time <same command>'" "tests=tl run 'npm test'"Report before/after numbers. No numbers means no verified gain.
- Do not optimize cold paths.
- Keep benchmark input stable between runs.
- If tradeoffs exist (speed vs memory), document them explicitly.