Advertisement
Guest User

Decorator to use Line_Profiler from within a script

a guest
Apr 17th, 2020
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. def profile_line(fn):
  2.     def deco(func):
  3.         def wrapper(*args, **kwargs):
  4.             lp = LineProfiler()
  5.             lp_wrapper = lp(func)
  6.             ret_fun = lp_wrapper(*args, **kwargs)
  7.             lp.print_stats()
  8.             return ret_fun
  9.         return wrapper
  10.     return deco(fn)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement