perfy
Perfy - a lightweight profiling tool for Python
Mark your functions and methods as trace-enabled with @perfy decorator:
@perfy
def trace_this_function():
# do something
Also, you can trace arbitrary blocks of your code using with statement:
with perfy('name of your choice'):
# your code here
After running your code, print report using
perfy.report()
Example:
from time import sleep
from perfy import perfy
@perfy # <-- use decorator to track function calls
def func_sleep():
sleep(.02)
def sleep_loop():
with perfy('sleep loop'): # <-- use with-statement to track arbitrary block of code
for _ in range(10):
func_sleep()
# you can nest with-blocks and decorated function calls in any order:
@perfy # <-- a decorator on a top level function
def main():
sleep_loop() # <-- this functions has a traced block inside
with perfy('custom named block'): # <-- traced block
sleep(.1)
with perfy('inner block'): # <-- nested traced block
func_sleep()
func_sleep()
For above code perfy.report() will output:
----------------------------------Perfy report----------------------------------
Function/Method Time(sec.) Calls(count)
--------------------------------------------------------------------------------
main 0.350 1
└ sleep loop 0.206 1
└ func_sleep 0.205 10
└ custom named block 0.144 1
└ inner block 0.043 1
└ func_sleep 0.042 2
--------------------------------------------------------------------------------
Metadata
Release files for perfy 0.27
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| perfy-0.27.tar.gz | 3.1 kB | Without provenance | Details for perfy-0.27.tar.gz |
Release files / perfy-0.27.tar.gz
| Download URL | perfy-0.27.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
633e27054433aab445bb95d4726714fcf688da12c63c0b5ff0bb5155be79cdd0
|
|
BLAKE2b-256 checksum How to use checksums |
a3ed9ec8600948de5142618d6ad3f3ff22a72190e89ae59ec496c3dd119659f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.7
|
Security for perfy 0.27
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.