Skip to content

Rahgooy/profiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Profiler

A python package providing simple profiling tools and reports.

Installation

Run

pip install profilerpy

or

pip install git+https://github.com/Rahgooy/profiler.git@master

Usage

Methods

Profiler can be used as a wrapper for the files. For example:

from profilerpy import profile
@profile
def add(a, b):
  return a + b

Code blocks

Another 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')

Print summary

Finally you can print the profiling summary

default_profiler.print_profile()

Multiple profilers

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

Functions with custom names

@profile('FancyName')
def method1():
  pass

About

A python package providing simple profiling tools and reports

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages