Merge pull request #31814 from sagarvora/restrict-cprofile-output
fix(DX): limit cprofiler output to 200 lines
This commit is contained in:
commit
c5f79016eb
2 changed files with 4 additions and 4 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue