Skip to main content

Perfy - a lightweight performance tracer for python

Project description


Perfy - a lightweight profiling tool for Python

Mark your functions and methods as trace-enabled with @perfy decorator:

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


from time import sleep
from perfy import perfy

@perfy # <-- use decorator to track function calls
def func_sleep():

def sleep_loop():
   with perfy('sleep loop'): # <-- use with-statement to track arbitrary block of code
      for _ in range(10):

# 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

      with perfy('inner block'): # <-- nested traced block

For above code 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          

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for perfy, version 0.27
Filename, size File type Python version Upload date Hashes
Filename, size perfy-0.27.tar.gz (3.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page