Agent skill
profile-code
Measure execution time and memory usage of code. Use when analyzing performance characteristics.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/profile-code
SKILL.md
Profile Code
Use profiling tools to measure CPU time, memory allocation, and identify performance bottlenecks in code.
When to Use
- Finding performance bottlenecks
- Measuring CPU vs memory tradeoffs
- Understanding where code spends most time
- Optimizing hot code paths
Quick Reference
# Python CPU profiling with cProfile
python3 -m cProfile -s cumulative script.py | head -30
# Memory profiling
pip install memory-profiler
python3 -m memory_profiler script.py
# Detailed call graph
pip install graphviz
python3 -m pstats /tmp/profile.prof
Workflow
- Select profiler: Choose appropriate tool (cProfile for CPU, memory_profiler for memory)
- Run with instrumentation: Execute code with profiling enabled
- Capture metrics: Record timing and memory data
- Analyze output: Identify top time consumers and memory hogs
- Report findings: Document bottlenecks with before/after context
Output Format
Profiling report:
- Top functions by execution time
- Call count for each function
- Memory allocation per function
- Call graph/call tree
- Percentage of total time/memory per function
- Recommendations for optimization
References
- See
suggest-optimizationsskill for improvement recommendations - See
benchmark-functionsskill for measuring improvements - See CLAUDE.md > Performance for optimization guidelines
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?