Add metrics for view/task time

This commit is contained in:
Raphael Michel
2017-03-25 21:38:42 +01:00
parent f2378168c1
commit 4514bd7e53
7 changed files with 25 additions and 10 deletions

View File

@@ -26,10 +26,10 @@ class CProfileMiddleware(object):
if settings.PROFILING_RATE > 0 and random.random() < settings.PROFILING_RATE / 100:
profiler = cProfile.Profile()
profiler.enable()
starttime = time.time()
starttime = time.perf_counter()
response = self.get_response(request)
profiler.disable()
tottime = time.time() - starttime
tottime = time.perf_counter() - starttime
profiler.dump_stats(os.path.join(settings.PROFILE_DIR, '{time:.0f}_{tottime:.3f}_{path}.pstat'.format(
path=request.path[1:].replace("/", "_"), tottime=tottime, time=time.time()
)))