performance-profiling

Profile Python CPU, memory, and async performance with cProfile and memory_profiler.

2|Updated Nov 13, 2025
One-click install
npx skills add https://github.com/ricardoroche/ricardos-claude-code --skill performance-profiling-ricardoroche
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: performance-profiling
Source: https://github.com/ricardoroche/ricardos-claude-code/tree/main/.claude/skills/performance-profiling
Command: npx skills add https://github.com/ricardoroche/ricardos-claude-code --skill performance-profiling-ricardoroche

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires cProfile, pstats, line_profiler, memory_profiler, tracemalloc, asyncio, timeit, pytest.

What problem does it solve?

This Skill automates the complex and often time-consuming process of identifying performance bottlenecks in Python applications. It helps developers quickly understand where their code is slow, consumes too much memory, or has inefficient I/O, eliminating guesswork and manual instrumentation.

Core Features & Use Cases

  • Comprehensive Profiling: Utilizes cProfile for CPU, line_profiler for line-by-line, and memory_profiler for memory analysis.
  • Async & Benchmarking: Provides patterns for profiling asynchronous Python code and benchmarking different implementations to compare performance.
  • Optimization Strategies: Guides the user through best practices for identifying hot paths, setting performance budgets, and avoiding common anti-patterns.
  • Use Case: A backend engineer needs to speed up a slow API endpoint. This skill can guide them to apply CPU, memory, and async profiling to pinpoint the exact functions causing the slowdown, then suggest benchmarking alternatives for optimization.

Quick Start

Profile the process_data function in my Python application to identify CPU bottlenecks.

Frequently Asked Questions about performance-profiling

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I identify CPU bottlenecks in my Python application?

CPU profiling identifies bottlenecks by measuring function execution time and call frequency. Use cProfile to capture which functions consume the most processor time, then analyze results with pstats to pinpoint hot paths requiring optimization.

Can I profile memory usage in Python to find memory leaks?

Memory profiling tracks heap allocation line-by-line and across your entire application. memory_profiler and tracemalloc reveal which functions or code sections allocate excessive memory, helping you identify leaks and optimize memory-intensive operations.

How do I profile asynchronous Python code for performance issues?

Async profiling applies CPU and memory profiling techniques to asyncio-based applications, capturing coroutine execution time and resource consumption. This identifies bottlenecks in concurrent tasks without disrupting async scheduling.

What's the best way to benchmark different Python implementations to compare performance?

Benchmarking measures execution time across alternative implementations using timeit and profiling decorators. Line-level and function-level profiling reveals which variant performs better under specific conditions, guiding optimization choices.

Can I export profiling data for analysis outside my development environment?

Profiling results integrate with cProfile and pstats for structured data export and reporting. This enables bottleneck analysis across development, staging, and production environments with persistent records for trend tracking.

Do I need to add profiling code throughout my application or can I use decorators?

Profiling supports both decorator-based and context-manager approaches for minimal code intrusion. Decorators attach profiling to specific functions; context managers wrap code blocks, enabling targeted analysis without rewriting your entire application.