diff --git a/frappe/app.py b/frappe/app.py index 9373689380..d5114ab019 100644 --- a/frappe/app.py +++ b/frappe/app.py @@ -477,7 +477,7 @@ def serve( from werkzeug.serving import run_simple if profile or os.environ.get("USE_PROFILER"): - application = ProfilerMiddleware(application, sort_by=("cumtime", "calls")) + application = ProfilerMiddleware(application, sort_by=("cumtime", "calls"), restrictions=(200,)) if not os.environ.get("NO_STATICS"): application = application_with_statics() diff --git a/frappe/recorder.py b/frappe/recorder.py index d3eac91a00..c5318d1056 100644 --- a/frappe/recorder.py +++ b/frappe/recorder.py @@ -251,7 +251,7 @@ class Recorder: profiler_output = io.StringIO() pstats.Stats(self.profiler, stream=profiler_output).strip_dirs().sort_stats( "cumulative" - ).print_stats() + ).print_stats(200) profile = profiler_output.getvalue() profiler_output.close() return profile @@ -259,7 +259,7 @@ class Recorder: def dump(self): if not self._recording: return - profiler_output = self.process_profiler() or "" + profiler_output = self.process_profiler() request_data = { "uuid": self.uuid, @@ -277,7 +277,7 @@ class Recorder: request_data["calls"] = self.calls request_data["headers"] = self.headers request_data["form_dict"] = self.form_dict - request_data["profile"] = "".join(profiler_output.splitlines(keepends=True)[:200]) + request_data["profile"] = profiler_output frappe.cache.hset(RECORDER_REQUEST_HASH, self.uuid, request_data) if self.config.record_sql: