Skip to content

Instantly share code, notes, and snippets.

@EtsuNDmA
Created April 3, 2019 13:08
Show Gist options
  • Save EtsuNDmA/a1b1bbcf107bd56b4147787b7c3f0bbf to your computer and use it in GitHub Desktop.
Save EtsuNDmA/a1b1bbcf107bd56b4147787b7c3f0bbf to your computer and use it in GitHub Desktop.
Decorator for line profiler
def profile(func):
import functools
@functools.wraps(func)
def inner(*args, **kwargs):
from line_profiler import LineProfiler
lp = LineProfiler()
lp_wrapper = lp(func)
result = lp_wrapper(*args, **kwargs)
lp.print_stats()
return result
return inner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment