Simple Python decorator to dump cProfile stats
Project description
dull
This is a plain and boring package providing one decorator for dumping profile stats to console or to a file for further inspections.
There are a million of nice packages providing decorators and context managers that can dump cProfile stats and generate visual stuff from them. But usually that is a little too much for just taking a peek at performance of a function. I found myself writing this wrapper again and again or copypasting it around, so why not package it for convenience?
Install with pip:
pip install dull
Wrap a function with profiler:
from dull import profile
@profile()
def foo():
print("well hello")
print("hello there")
foo()
print("goodbye")
Output:
hello there
well hello
---------------------------------------profile foo---------------------------------------
3 function calls in 0.000 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 joku.py:4(foo)
1 0.000 0.000 0.000 0.000 {built-in method builtins.print}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
-----------------------------------------------------------------------------------------
goodbye
Dump profile to file:
@profile(to_file=True) # output defaults to profile/foo.dat
def foo():
print("well hello")
Output:
hello there
well hello
--------------------------foo: profile saved to profile/foo.dat--------------------------
goodbye
Files are plain pstat dumps, get fancy with snakeviz or similar visualizers:
snakeviz profile/foo.dat
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dull-1.0.0.tar.gz
.
File metadata
- Download URL: dull-1.0.0.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.4.0-110-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 513944e2896c9a1054a86a905486471e2c4425ab3063153ca9df6324167da689 |
|
MD5 | 3b6c0b62c51179420961eae8590c048a |
|
BLAKE2b-256 | f5096af73e4ad7631109fcc252a45f02b7f2fd65e2ba526d00cf387fcb25e2e6 |
File details
Details for the file dull-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: dull-1.0.0-py3-none-any.whl
- Upload date:
- Size: 2.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.4.0-110-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a6fa94feb925c92126a8b39827d5a3c36312792cf6923d6c1c63ec137075d6f |
|
MD5 | 81fce07651d53ade7246ea4bd2c54daa |
|
BLAKE2b-256 | 645b3d3d36320e712b2efde7f4bb49c1acbf859b6a5cdb5b490a857430ec29de |