profit¶
A small, focused Python profiler built on sys.monitoring (Python 3.12+). Measures
wall time per function with minimal overhead — no sampling, no instrumentation of your
source, no configuration required.
-
Quick start
Profile any script with a single command — no setup, no config.
-
CLI reference
Every flag for
profit runandprofit timeit. -
Python API
Use
profitas a decorator or context manager, or driveProfilerdirectly. -
Low overhead
Built on
sys.monitoring(Python 3.12+) — no sampling, no source instrumentation.
Installation¶
Quick start¶
Profile a script¶
This instruments every Python function and C extension call in the script and prints a table sorted by cumulative time.
Focus on one function¶
Use -p to zoom in on a specific function instead of seeing the full call tree:
Compare two implementations¶
Use -b (baseline) and -p (profile) together to see how one implementation compares
to another:
The output includes a Delta column showing the mean time difference and a ratio relative to the baseline.
Time a statement in a loop¶
The number of iterations is chosen automatically so the total run takes around 0.2 s,
similar to Python's built-in timeit module.
Python API¶
profit also works as a decorator or context manager for profiling code directly:
Python 3.12+
profit uses sys.monitoring, which was introduced in Python 3.12. It will not
work on older versions.