Skip to content

A decorator to profile the run time of functions/classes/modules

License

Notifications You must be signed in to change notification settings

ekhoda/profile_decorator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Profile Decorator

A decorator to profile the run time of functions/classes/modules along with an example to show its usage.

The profile decorator doesn't print the results in stdout. Instead, the results are sent to a file. The decorator accepts the following keyword arguments:

  1. output_file (optional, default = None): path of the output file. If not given, the name of the decorated function is used.
  2. sort_by (optional, default = 'cumulative'): sorting criteria that can be a str, SortKey enum, or a tuple/list of those.
  3. lines_to_print (optional, default = None): number of lines to print. If None all the lines are printed.
  4. strip_dirs (optional, default = False): whether to remove the leading path info from file names.

For those interested, I wrote this blog and explained different ways of profiling in more detail.

About

A decorator to profile the run time of functions/classes/modules

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages