document ANKI_PROFILE_CODE and add bazel command to run snakeviz

This commit is contained in:
Damien Elmes 2020-12-17 12:03:24 +10:00
parent 1020381ca3
commit 32b6e8e198
5 changed files with 21 additions and 0 deletions

View file

@ -210,6 +210,8 @@ If TRACESQL is set, all sql statements will be printed as they are executed.
If LOGTERM is set before starting Anki, warnings and error messages that are normally placed
in the collection2.log file will also be printed on stdout.
If ANKI_PROFILE_CODE is set, Python profiling data will be written on exit.
## Cleaning
Unlike the old Make system, a "clean build" should almost never be required

View file

@ -17,6 +17,7 @@ pylint
pytest
requests[socks]
send2trash
snakeviz
stringcase
waitress
fluent-syntax

View file

@ -128,3 +128,12 @@ py_binary(
"//qt/aqt:aqt_with_data",
],
)
py_binary(
name = "profile",
srcs = ["tools/profile.py"],
tags = ["manual"],
deps = [
requirement("snakeviz"),
],
)

View file

@ -392,6 +392,7 @@ def write_profile_results():
profiler.disable()
profiler.dump_stats("anki.prof")
print("profile stats written to anki.prof")
print("use 'bazel run qt:profile' to explore")
def run():

8
qt/tools/profile.py Executable file
View file

@ -0,0 +1,8 @@
import sys, os
import snakeviz
from snakeviz.cli import main
profile = os.path.join(os.environ["BUILD_WORKSPACE_DIRECTORY"], "anki.prof")
sys.argv.append(profile)
sys.exit(main())