mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Reenabled site generation profiling
This commit is contained in:
parent
6b39ca8b19
commit
1c2062c512
@ -11,24 +11,30 @@ from ..globalconf import data_dir
|
||||
|
||||
profiler = cProfile.Profile()
|
||||
|
||||
FULL_PROFILE = False
|
||||
|
||||
def profile(func):
|
||||
def newfunc(*args,**kwargs):
|
||||
|
||||
benchmarkfolder = data_dir['logs']("benchmarks")
|
||||
os.makedirs(benchmarkfolder,exist_ok=True)
|
||||
if FULL_PROFILE:
|
||||
benchmarkfolder = data_dir['logs']("benchmarks")
|
||||
os.makedirs(benchmarkfolder,exist_ok=True)
|
||||
|
||||
clock = Clock()
|
||||
clock.start()
|
||||
|
||||
profiler.enable()
|
||||
if FULL_PROFILE:
|
||||
profiler.enable()
|
||||
result = func(*args,**kwargs)
|
||||
profiler.disable()
|
||||
|
||||
if FULL_PROFILE:
|
||||
profiler.disable()
|
||||
|
||||
log(f"Executed {func.__name__} ({args}, {kwargs}) in {clock.stop():.2f}s",module="debug_performance")
|
||||
try:
|
||||
pstats.Stats(profiler).dump_stats(os.path.join(benchmarkfolder,f"{func.__name__}.stats"))
|
||||
except:
|
||||
pass
|
||||
if FULL_PROFILE:
|
||||
try:
|
||||
pstats.Stats(profiler).dump_stats(os.path.join(benchmarkfolder,f"{func.__name__}.stats"))
|
||||
except:
|
||||
pass
|
||||
|
||||
return result
|
||||
|
||||
|
@ -236,6 +236,7 @@ def static(path):
|
||||
|
||||
### DYNAMIC
|
||||
|
||||
@profile
|
||||
def jinja_page(name):
|
||||
if name in aliases: redirect(aliases[name])
|
||||
keys = remove_identical(FormsDict.decode(request.query))
|
||||
|
Loading…
Reference in New Issue
Block a user