python-profiler
Skill0 starsChanged 13 months agoMITView on GitHub
Advanced Python profiling for CPU, memory, and performance bottleneck detection
- Installs packages
In this repository16 other files it gives its agents.
- aws-cost-analyzerSkill
- code-reviewerSkill
- dast-scannerSkill
- database-optimizerSkill
- dependency-checkerSkill
- git-workflowSkill
- java-profilerSkill
- jira-integrationSkill
- memory-analyzerSkill
- penetration-testerSkill
- performance-monitorSkill
- refactoring-assistantSkill
- sast-analyzerSkill
- security-scannerSkill
- skill-validatorSkill
- tdd-workflowSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 104
Run cProfile to identify slow functions
- Distinctive: line 107
Check memory usage with memory_profiler
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Python Profiler Skill
Overview
Comprehensive Python profiling skill that integrates multiple profiling tools to identify performance bottlenecks, memory leaks, and optimization opportunities in Python applications.
Capabilities
1. CPU Profiling
- cProfile: Built-in profiler for function-level analysis
- Pyinstrument: Visual call stack with flame graphs
- py-spy: Low-overhead sampling profiler for production
- line_profiler: Line-by-line performance analysis
2. Memory Profiling
- memory_profiler: Track memory usage line-by-line
- Scalene: Combined CPU + memory profiling
- Pyroscope: Continuous real-time profiling
3. Concurrency Profiling
- Yappi: Profile multithreading and greenlets/coroutines
- Thread-safe profiling for asyncio applications
Usage
Basic CPU Profiling
# Using cProfile
python -m cProfile -o output.prof your_script.py
# Using Pyinstrument
pyinstrument --html your_script.pyMemory Analysis
# Using memory_profiler
from memory_profiler import profile
@profile
def my_function():
# Your code here
passProduction Profiling
# Using py-spy (no code changes needed)
py-spy record -o profile.svg --pid <process_id>Integration Scripts
detect_bottleneck.py
Automatically runs multiple profilers and generates comprehensive reports:
#!/usr/bin/env python3
import cProfile
import pstats
from pyinstrument import Profiler
def profile_function(func):
"""Profile a function with multiple tools"""
# cProfile analysis
profiler = cProfile.Profile()
profiler.enable()
result = func()
profiler.disable()
stats = pstats.Stats(profiler)
stats.sort_stats('cumulative')
stats.print_stats(20)
return resultBest Practices
- Start with cProfile for high-level overview
- Use Pyinstrument to visualize call hierarchies
- Apply line_profiler to specific bottleneck functions
- Monitor memory with memory_profiler for large datasets
- Use py-spy in production (no overhead, no code changes)
Output Interpretation
- cumtime: Total time in function + subcalls
- tottime: Time in function excluding subcalls
- ncalls: Number of times function was called
- percall: Average time per call
Requirements
pip install cProfile pyinstrument memory-profiler py-spy line-profiler scalene yappiExample Workflow
- Run cProfile to identify slow functions
- Visualize with Pyinstrument flame graph
- Deep-dive with line_profiler on specific functions
- Check memory usage with memory_profiler
- Optimize and re-profile to confirm improvements
Common Bottlenecks to Look For
- Nested loops with high iteration counts
- Inefficient list comprehensions
- Repeated string concatenations
- Unoptimized pandas operations
- Missing database query optimizations (N+1 queries)
- Synchronous I/O in async code
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

