A python package providing simple profiling tools and reports.
Run
pip install profilerpyor
pip install git+https://github.com/Rahgooy/profiler.git@masterProfiler can be used as a wrapper for the files. For example:
from profilerpy import profile
@profile
def add(a, b):
return a + bAnother usage is for profiling a block of code:
from profilerpy import default_profiler
# Some line of code
default_profiler.start('Price calculator')
# Price calculator codes
default_profiler.finish('Price calculator')Finally you can print the profiling summary
default_profiler.print_profile()This package uses dafult_profiler by default. However, you can use multiple instances of the profiler class.
For example:
from profilerpy import Profiler, profile
priceProfiler = Profiler() # Profile the codes related to calculating price
userProfiler = Profiler() # Profile the codes related to the user management
# Some lines of code
userProfiler.start('Find user')
# Find user codes
userProfile.finish('Find user')
# ...
default_profiler.start('Price calculator')
# Price calculator codes
default_profiler.finish('Price calculator')
@profile('update_user', profiler=userProfiler)
def update_user(user):
pass@profile('FancyName')
def method1():
pass