Skip to main content

Profiler Cub 🐻

pypi version

A beautiful Python code profiling library with rich terminal visualizations. Profile your code, categorize by layers, analyze dependencies, and get gorgeous color-coded performance reports.

Features

  • 🎨 Beautiful Rich Visualizations - Color-coded tables with performance gradients
  • 📊 Layer-based Categorization - Organize code into logical layers (Core, API, Database, etc.)
  • 🔍 Dependency Analysis - See exactly how much time external libraries consume
  • ⏱️ Import vs Runtime Tracking - Separate module load time from execution time
  • 🎯 Filtering & Sorting - Multiple sort modes and threshold filtering
  • 🔄 Multiple Iterations - Run workloads multiple times for stable measurements

Installation

pip install profiler-cub

With uv:

uv tool install profiler-cub

Quick Start

from pathlib import Path
from profiler_cub.core import CodeProfiler
from profiler_cub.display import display_all
from funcy_bear.tools.gradient import ColorGradient

# Create profiler
profiler = CodeProfiler(
    pkg_name="my_package",
    threshold_ms=0.5,  # Filter functions below 0.5ms
)

# Profile your code
def my_workload():
    # Your code here
    pass

profiler.run(my_workload, stats_file=Path("profile.stats"))

# Display beautiful results
gradient = ColorGradient(start_color="#00ff00", end_color="#ff0000")
display_all(profiler, color_gradient=gradient)

Layer-Based Profiling

Organize your code into logical layers for better insights:

profiler = CodeProfiler(
    pkg_name="my_app",
    module_map={
        "Database": {"db/", "models/"},
        "API": {"api/", "routes/"},
        "Core": {"core/", "engine/"},
    }
)

The profiler will categorize each function by its filepath and show aggregated stats per layer.

Examples

Check out the examples/ directory for complete examples:

  • simple_example.py - Minimal setup, get started quickly
  • profile_example.py - Full-featured with CLI args, setup/teardown, iterations

See examples/README.md for detailed usage.

Documentation

For comprehensive documentation, see CLAUDE.md which includes:

  • Complete architecture overview
  • All configuration options
  • Key concepts (layers, sort modes, thresholds, etc.)
  • Real-world usage patterns

Development

# Install dependencies
uv sync

# Run tests
nox -s tests

# Run linting
nox -s ruff_fix

# Run type checking
nox -s pyright

License

MIT

Credits

Created by Bear 🐻 with love for performance analysis.

Metadata

Release files for profiler-cub 0.0.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for profiler-cub 0.0.12
File Interpreter ABI Platform
profiler_cub-0.0.12-py3-none-any.whl Python 3 none any Details

Release files / profiler_cub-0.0.12-py3-none-any.whl

Download URL profiler_cub-0.0.12-py3-none-any.whl
Size 22.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65e50e5758efabbe2de02d1ec1c53a25d7726c71ec3e0a12a6e9349c4b56a027
BLAKE2b-256 checksum
How to use checksums
a12ac37c1876d4c76d06f9555f50149f566866d4f042397f4d503d702f9d1a06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

Security for profiler-cub 0.0.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 1 file in this release has been uploaded with provenance metadata.

Attestation for profiler_cub-0.0.12-py3-none-any.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.12 This release

1 release file Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page