Profile application performance, identify bottlenecks, and optimize hot paths using CPU profiling, flame graphs, and benchmarking. Use when investigating performance issues or optimizing critical code paths.
Profile code execution to identify performance bottlenecks and optimize critical paths using data-driven approaches.
Minimal working example:
import { performance, PerformanceObserver } from "perf_hooks";
class Profiler {
private marks = new Map<string, number>();
mark(name: string): void {
this.marks.set(name, performance.now());
}
measure(name: string, startMark: string): number {
const start = this.marks.get(startMark);
if (!start) throw new Error(`Mark ${startMark} not found`);
const duration = performance.now() - start;
console.log(`${name}: ${duration.toFixed(2)}ms`);
return duration;
}
async profile<T>(name: string, fn: () => Promise<T>): Promise<T> {
const start = performance.now();
try {
return await fn();
} finally {
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents | |---|---| | Node.js Profiling | Node.js Profiling | | Chrome DevTools CPU Profile | Chrome DevTools CPU Profile | | Python cProfile | Python cProfile | | Benchmarking | Benchmarking | | Database Query Profiling | Database Query Profiling | | Flame Graph Generation | Flame Graph Generation |
Copy a source-pinned command for your client. You run it yourself.
Destination: .claude/skills/profiling-optimization · pinned to the source commit
git clone https://github.com/aj-geddes/useful-ai-prompts.git
cd useful-ai-prompts
git checkout 3f5182cfd739fc113f4af5244a1cf342ad7f7911
mkdir -p ".claude/skills/profiling-optimization"
cp -r "skills/profiling-optimization" ".claude/skills/profiling-optimization"Review the source before running. This copies files into your project; it is not a one-click install and does not verify runtime safety.
Scanner static-checks@0.1.0 · commit 3f5182cfd739. Static checks cannot prove runtime safety – review the source and the exact diff before installing. How checks work.
No static rules matched. This is not a safety guarantee.