mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
save profile stats to file instead of generating report
Can use an external tool like snakeviz to query them after a run.
This commit is contained in:
parent
f6767d1cff
commit
578b60c104
2 changed files with 5 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -10,3 +10,4 @@ dist
|
|||
pyenv
|
||||
.mypy_cache
|
||||
__pycache__
|
||||
anki.prof
|
||||
|
|
|
@ -351,16 +351,10 @@ def setupGL(pm):
|
|||
PROFILE_CODE = os.environ.get("ANKI_PROFILE_CODE")
|
||||
|
||||
|
||||
def print_profile_results():
|
||||
import io
|
||||
import pstats
|
||||
|
||||
def write_profile_results():
|
||||
profiler.disable()
|
||||
outputstream = io.StringIO()
|
||||
profiler_status = pstats.Stats(profiler, stream=outputstream)
|
||||
profiler_status.sort_stats("time")
|
||||
profiler_status.print_stats()
|
||||
sys.stderr.write(f"\n{outputstream.getvalue()}\n")
|
||||
profiler.dump_stats("anki.prof")
|
||||
print("profile stats written to anki.prof")
|
||||
|
||||
|
||||
def run():
|
||||
|
@ -516,4 +510,4 @@ environment points to a valid, writable folder.""",
|
|||
return app
|
||||
|
||||
if PROFILE_CODE:
|
||||
print_profile_results()
|
||||
write_profile_results()
|
||||
|
|
Loading…
Reference in a new issue