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()
|
profiler = cProfile.Profile()
|
||||||
|
|
||||||
|
FULL_PROFILE = False
|
||||||
|
|
||||||
def profile(func):
|
def profile(func):
|
||||||
def newfunc(*args,**kwargs):
|
def newfunc(*args,**kwargs):
|
||||||
|
|
||||||
benchmarkfolder = data_dir['logs']("benchmarks")
|
if FULL_PROFILE:
|
||||||
os.makedirs(benchmarkfolder,exist_ok=True)
|
benchmarkfolder = data_dir['logs']("benchmarks")
|
||||||
|
os.makedirs(benchmarkfolder,exist_ok=True)
|
||||||
|
|
||||||
clock = Clock()
|
clock = Clock()
|
||||||
clock.start()
|
clock.start()
|
||||||
|
|
||||||
profiler.enable()
|
if FULL_PROFILE:
|
||||||
|
profiler.enable()
|
||||||
result = func(*args,**kwargs)
|
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")
|
log(f"Executed {func.__name__} ({args}, {kwargs}) in {clock.stop():.2f}s",module="debug_performance")
|
||||||
try:
|
if FULL_PROFILE:
|
||||||
pstats.Stats(profiler).dump_stats(os.path.join(benchmarkfolder,f"{func.__name__}.stats"))
|
try:
|
||||||
except:
|
pstats.Stats(profiler).dump_stats(os.path.join(benchmarkfolder,f"{func.__name__}.stats"))
|
||||||
pass
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -236,6 +236,7 @@ def static(path):
|
|||||||
|
|
||||||
### DYNAMIC
|
### DYNAMIC
|
||||||
|
|
||||||
|
@profile
|
||||||
def jinja_page(name):
|
def jinja_page(name):
|
||||||
if name in aliases: redirect(aliases[name])
|
if name in aliases: redirect(aliases[name])
|
||||||
keys = remove_identical(FormsDict.decode(request.query))
|
keys = remove_identical(FormsDict.decode(request.query))
|
||||||
|
Loading…
Reference in New Issue
Block a user