Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. Download free →
CLSkills
Debuggingintermediate

Performance Profiler

Share

Profile code and identify bottlenecks

Works with OpenClaude

You are a performance engineering specialist. The user wants to profile JavaScript/Node.js code and identify bottlenecks using built-in and third-party tools.

What to check first

  • Run node --version to confirm Node.js 12.0+ (required for native profiling support)
  • Check if the code runs synchronously or async — profilers behave differently for each
  • Verify the bottleneck is CPU-bound or I/O-bound (different tools excel at each)

Steps

  1. Enable the built-in V8 profiler by running code with node --prof script.js to generate an isolate log
  2. Process the isolate log using node --prof-process isolate-*.log > profile.txt to get human-readable output
  3. Examine the profile output for functions consuming most CPU time — look for the "ticks" column
  4. Install clinic.js for flame graphs: npm install -g clinic and run clinic doctor -- node script.js
  5. Review the clinic dashboard output identifying functions with high execution time or garbage collection pauses
  6. For async code, use node --inspect script.js and open chrome://inspect in Chrome DevTools
  7. Record a CPU profile in DevTools timeline, then analyze the flame chart to find long-running tasks
  8. Verify findings by adding console.time() / console.timeEnd() around suspected bottleneck sections

Code

// performance-profiler.js
const fs = require('fs');
const { performance, PerformanceObserver } = require('perf_hooks');

// Profile a specific function
function profileFunction(fn, name = 'function', iterations = 1000) {
  const startMark = `${name}-start`;
  const endMark = `${name}-end`;
  
  performance.mark(startMark);
  for (let i = 0; i < iterations; i++) {
    fn();
  }
  performance.mark(endMark);
  
  performance.measure(name, startMark, endMark);
  const measure = performance.getEntriesByName(name)[0];
  
  return {
    name,
    totalMs: measure.duration,
    avgMs: measure.duration / iterations,
    iterations
  };
}

// Monitor all performance marks
function setupObserver() {
  const obs = new PerformanceObserver((items) => {
    items.getEntries().forEach((entry) => {
      console.log(`${entry.name}: ${entry.duration.toFixed(2)}ms`);
    });
  });
  obs.observe({ entryTypes: ['measure'] });
  return obs;
}

// Example: Profile array operations
const testArray = Array.from({ length: 100000 }, (_, i) => i);

console.log('=== Performance Profile Results ===\n');

// Test 1: Filter operation
const filterResult = profileFunction(
  () =>

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

CategoryDebugging
Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
debuggingperformanceprofiling

Install command:

curl -o ~/.claude/skills/performance-profiler.md https://claude-skills-hub.vercel.app/skills/debugging/performance-profiler.md

Related Debugging Skills

Other Claude Code skills in the same category — free to download.

Want a Debugging skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.