Refactored Caching, Refactored BnfNodeParser, Introduced Sphinx
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
# ############################
|
||||
# from github: nealtodd/decorator.py
|
||||
# ############################
|
||||
|
||||
import pstats
|
||||
from cProfile import Profile
|
||||
|
||||
|
||||
def profile(sort_args=None, print_args=None):
|
||||
sort_args = sort_args or ['cumulative']
|
||||
print_args = print_args or [10]
|
||||
profiler = Profile()
|
||||
|
||||
def decorator(fn):
|
||||
def inner(*args, **kwargs):
|
||||
result = None
|
||||
try:
|
||||
result = profiler.runcall(fn, *args, **kwargs)
|
||||
finally:
|
||||
stats = pstats.Stats(profiler)
|
||||
stats.strip_dirs().sort_stats(*sort_args).print_stats(*print_args)
|
||||
return result
|
||||
|
||||
return inner
|
||||
|
||||
return decorator
|
||||
Reference in New Issue
Block a user