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
|
pyenv
|
||||||
.mypy_cache
|
.mypy_cache
|
||||||
__pycache__
|
__pycache__
|
||||||
|
anki.prof
|
||||||
|
|
|
@ -351,16 +351,10 @@ def setupGL(pm):
|
||||||
PROFILE_CODE = os.environ.get("ANKI_PROFILE_CODE")
|
PROFILE_CODE = os.environ.get("ANKI_PROFILE_CODE")
|
||||||
|
|
||||||
|
|
||||||
def print_profile_results():
|
def write_profile_results():
|
||||||
import io
|
|
||||||
import pstats
|
|
||||||
|
|
||||||
profiler.disable()
|
profiler.disable()
|
||||||
outputstream = io.StringIO()
|
profiler.dump_stats("anki.prof")
|
||||||
profiler_status = pstats.Stats(profiler, stream=outputstream)
|
print("profile stats written to anki.prof")
|
||||||
profiler_status.sort_stats("time")
|
|
||||||
profiler_status.print_stats()
|
|
||||||
sys.stderr.write(f"\n{outputstream.getvalue()}\n")
|
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
@ -516,4 +510,4 @@ environment points to a valid, writable folder.""",
|
||||||
return app
|
return app
|
||||||
|
|
||||||
if PROFILE_CODE:
|
if PROFILE_CODE:
|
||||||
print_profile_results()
|
write_profile_results()
|
||||||
|
|
Loading…
Reference in a new issue