performance-profiler

Performance analysis: complexity estimation, profiler output parsing, caching design, regression risk. Use for optimization guidance. NOT for running profilers, load tests, or monitoring.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "performance-profiler" with this command: npx skills add wyattowalsh/agents/wyattowalsh-agents-performance-profiler

Performance Profiler

Analysis-based performance review. Every recommendation grounded in evidence. 6-mode pipeline: Analyze, Profile, Cache, Benchmark, Regression, Leak-Patterns.

Scope: Performance analysis and recommendations only. NOT for running profilers, executing load tests, infrastructure monitoring, or actual memory leak detection. This skill provides analysis-based guidance, not measurements.

Canonical Vocabulary

Use these terms exactly throughout all modes:

TermDefinition
complexityBig-O algorithmic classification of a function or code path
hotspotCode region with disproportionate resource consumption (time or memory)
bottleneckSystem constraint limiting overall throughput
profiler outputTextual data from cProfile, py-spy, perf, or similar tools pasted by user
cache strategyEviction policy + write policy + invalidation approach for a caching layer
benchmark skeletonTemplate code for measuring function performance with proper methodology
regression riskLikelihood that a code change degrades performance, scored LOW/MEDIUM/HIGH/CRITICAL
anti-patternKnown performance-harmful code pattern (N+1, unbounded allocation, etc.)
evidenceConcrete proof: AST analysis, profiler data, code pattern match, or external reference
recommendationActionable optimization suggestion with expected impact and trade-offs
flame graphHierarchical visualization of call stack sampling data
wall timeElapsed real time (includes I/O waits) vs CPU time (compute only)

Dispatch

$ARGUMENTSMode
analyze <file/function>Algorithmic complexity analysis, Big-O review
profile <data>Interpret textual profiler output (cProfile, py-spy, perf)
cache <system>Caching strategy design (LRU/LFU/TTL/write-through/write-back)
benchmark <code>Benchmark design and methodology review
regression <diff>Performance regression risk assessment from code diff
leak-patternsCommon memory leak pattern scan (NOT actual detection)
EmptyShow mode menu with examples for each mode

Mode 1: Analyze

Algorithmic complexity analysis for files or functions.

Analyze Step 1: Scan

Run the complexity estimator script:

uv run python skills/performance-profiler/scripts/complexity-estimator.py <path>

Parse JSON output. If script fails, perform manual AST-level analysis.

Analyze Step 2: Classify

For each function in scope:

  1. Identify loop nesting depth, recursion patterns, data structure operations
  2. Map to Big-O classification using references/complexity-patterns.md
  3. Score hotspot risk: nesting depth * call frequency * data size sensitivity
  4. Flag functions with O(n^2) or worse in hot paths

Analyze Step 3: Report

Present findings as a table:

FunctionEstimated ComplexityEvidenceHotspot RiskRecommendation

Include trade-off analysis for each recommendation.

Mode 2: Profile

Interpret textual profiler output pasted by the user.

Profile Step 1: Parse

Run the profile parser script on user-provided data:

uv run python skills/performance-profiler/scripts/profile-parser.py --input <file>

If data is inline, save to temp file first. Parse JSON output.

Profile Step 2: Identify Hotspots

From parsed data:

  1. Rank functions by cumulative time (top 10)
  2. Identify functions with high call count but low per-call time (overhead candidates)
  3. Identify functions with low call count but high per-call time (optimization candidates)
  4. Check for I/O-bound vs CPU-bound patterns (wall time vs CPU time ratio)

Profile Step 3: Recommend

For each hotspot, provide:

  • Root cause hypothesis with evidence from the profiler data
  • Optimization approach with expected impact range
  • Trade-offs and risks of the optimization
  • Reference to relevant anti-patterns from references/anti-patterns.md

Mode 3: Cache

Design caching strategies for a described system.

Cache Step 1: Understand Access Patterns

Ask about or infer from code:

  1. Read/write ratio
  2. Data freshness requirements (TTL tolerance)
  3. Cache size constraints
  4. Consistency requirements (eventual vs strong)
  5. Eviction pressure (working set vs cache capacity)

Cache Step 2: Design Strategy

Use references/caching-strategies.md decision tree:

FactorLRULFUTTLWrite-ThroughWrite-Back
Read-heavy, stable working setGoodBestOK----
Write-heavy------SafeFast
Strict freshness----BestBestRisky
Memory-constrainedBestGoodOK----

Cache Step 3: Specify

Deliver: eviction policy, write policy, invalidation strategy, warm-up approach, monitoring recommendations. Include capacity planning formula.

Mode 4: Benchmark

Design benchmarks and review methodology.

Benchmark Step 1: Generate Skeleton

Run the benchmark designer script:

uv run python skills/performance-profiler/scripts/benchmark-designer.py --function <signature> --language <lang>

Parse JSON output for setup code, benchmark code, iterations, warmup.

Benchmark Step 2: Review Methodology

Validate against benchmark best practices:

  1. Warmup period sufficient to stabilize JIT/caches
  2. Iteration count provides statistical significance
  3. Measurement excludes setup/teardown overhead
  4. Environment controlled (no interference from other processes)
  5. Results include variance/percentiles, not just mean

Benchmark Step 3: Deliver

Provide complete benchmark code with methodology notes, expected metrics, and interpretation guide.

Mode 5: Regression

Assess performance regression risk from a code diff.

Regression Step 1: Collect Diff

If path provided, read the diff. If git range provided, run git diff. Identify changed functions and their call sites.

Regression Step 2: Assess Risk

For each changed function:

Risk FactorWeightCheck
Complexity increase3xLoop nesting added, algorithm changed
Hot path change3xFunction called in request/render path
Data structure change2xCollection type or size assumptions changed
I/O pattern change2xNew network/disk calls, removed batching
Memory allocation1xNew allocations in loops, larger buffers

Risk score = sum of (weight * severity). Map to LOW/MEDIUM/HIGH/CRITICAL.

Regression Step 3: Report

Present regression risk matrix with:

  • Per-function risk assessment with evidence
  • Aggregate risk score for the diff
  • Recommended benchmark targets before merging
  • Specific measurements to validate (what to profile and where)

Mode 6: Leak-Patterns

Scan for common memory leak patterns. Static analysis only -- NOT actual leak detection.

Leak Step 1: Scan

Read target files and check against patterns in references/leak-patterns.md:

  • Event listener accumulation without cleanup
  • Closure-captured references preventing GC
  • Growing collections without bounds (unbounded caches, append-only lists)
  • Circular references in reference-counted languages
  • Resource handles not closed (files, connections, cursors)
  • Global state accumulation

Leak Step 2: Classify

For each potential leak pattern found:

PatternLanguageSeverityFalse Positive Risk

Leak Step 3: Report

Present findings with code citations, explain why each pattern risks leaking, and suggest fixes. Acknowledge that static analysis has high false positive rates -- recommend actual profiling tools for confirmation.

Scaling Strategy

ScopeStrategy
Single functionDirect analysis, inline report
Single file (< 500 LOC)Script-assisted analysis, structured report
Multiple files / moduleParallel subagents per file, consolidated report
Full codebasePrioritize entry points and hot paths, sample-based analysis

Reference Files

Load ONE reference at a time. Do not preload all references into context.

FileContentRead When
references/complexity-patterns.mdCode pattern to Big-O mapping with examplesMode 1 (Analyze)
references/caching-strategies.mdCaching decision tree, eviction policies, trade-offsMode 3 (Cache)
references/anti-patterns.mdPerformance anti-patterns catalog (N+1, unbounded alloc, etc.)Mode 2 (Profile), Mode 5 (Regression), Mode 6 (Leak)
references/leak-patterns.mdMemory leak patterns by language (Python, JS, Go, Java)Mode 6 (Leak-Patterns)
references/profiler-guide.mdProfiler output interpretation, flame graph readingMode 2 (Profile)
references/benchmark-methodology.mdBenchmark design best practices, statistical methodsMode 4 (Benchmark)
ScriptWhen to Run
scripts/complexity-estimator.pyMode 1 — static complexity analysis via AST
scripts/profile-parser.pyMode 2 — parse cProfile/pstats textual output to JSON
scripts/benchmark-designer.pyMode 4 — generate benchmark skeleton from function signature
TemplateWhen to Render
templates/dashboard.htmlAfter any mode — inject results JSON into data tag

Data Files

FileContent
data/complexity-patterns.jsonCode pattern to Big-O mapping (machine-readable)
data/caching-strategies.jsonCaching decision tree (machine-readable)
data/anti-patterns.jsonPerformance anti-patterns catalog (machine-readable)

Critical Rules

  1. Never claim to measure performance — this skill provides analysis, not measurement
  2. Every recommendation must include trade-offs — no "just do X" advice
  3. Always acknowledge uncertainty in complexity estimates — static analysis has limits
  4. Never recommend premature optimization — confirm the code is actually on a hot path first
  5. Profiler output interpretation must cite specific data points, not general principles
  6. Cache strategy recommendations must address invalidation — "cache invalidation is hard" is not a strategy
  7. Benchmark designs must include warmup, statistical significance, and variance reporting
  8. Regression risk assessment must trace to specific code changes, not general concerns
  9. Leak pattern scanning is pattern-matching only — always recommend actual profiling for confirmation
  10. Load ONE reference file at a time — do not preload all references into context
  11. Present findings with evidence before suggesting fixes (approval gate)
  12. Anti-pattern findings require code citation [file:line] — no generic warnings

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Research

research

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

honest-review

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

add-badges

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

orchestrator

No summary provided by upstream source.

Repository SourceNeeds Review