Skip to content

Instantly share code, notes, and snippets.

@dmitryhd
Last active October 29, 2018 14:44
Show Gist options
  • Select an option

  • Save dmitryhd/7fe4f11c73cf83cefead61a5b14e0ac2 to your computer and use it in GitHub Desktop.

Select an option

Save dmitryhd/7fe4f11c73cf83cefead61a5b14e0ac2 to your computer and use it in GitHub Desktop.
python line profiler
from line_profiler import LineProfiler
def profile_function(func, *args, **kwargs):
'''
Usage:
def long_function(x, y)
return x + y
z = profile_function(long_function, x=1, y=2)
'''
lp = LineProfiler()
lp_wrapper = lp(func)
rv = lp_wrapper(*args, **kwargs)
lp.print_stats()
return rv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment