benchmark->profile, and remove from error branches
This commit is contained in:
parent
e7ebcc7c75
commit
2f57c646e0
@ -348,17 +348,19 @@ def setupGL(pm):
|
||||
os.environ["QT_OPENGL"] = mode
|
||||
|
||||
|
||||
def printBenchmark():
|
||||
if os.environ.get("ANKI_RUN_BENCHMARK"):
|
||||
import io
|
||||
import pstats
|
||||
PROFILE_CODE = os.environ.get("ANKI_PROFILE_CODE")
|
||||
|
||||
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")
|
||||
|
||||
def print_profile_results():
|
||||
import io
|
||||
import pstats
|
||||
|
||||
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")
|
||||
|
||||
|
||||
def run():
|
||||
@ -392,7 +394,7 @@ def _run(argv=None, exec=True):
|
||||
# parse args
|
||||
opts, args = parseArgs(argv)
|
||||
|
||||
if os.environ.get("ANKI_RUN_BENCHMARK"):
|
||||
if PROFILE_CODE:
|
||||
import cProfile
|
||||
|
||||
profiler = cProfile.Profile()
|
||||
@ -440,7 +442,6 @@ def _run(argv=None, exec=True):
|
||||
Anki could not create its data folder. Please see the File Locations \
|
||||
section of the manual, and ensure that location is not read-only.""",
|
||||
)
|
||||
printBenchmark()
|
||||
return
|
||||
|
||||
# disable icons on mac; this must be done before window created
|
||||
@ -474,7 +475,6 @@ section of the manual, and ensure that location is not read-only.""",
|
||||
No usable temporary folder found. Make sure C:\\temp exists or TEMP in your \
|
||||
environment points to a valid, writable folder.""",
|
||||
)
|
||||
printBenchmark()
|
||||
return
|
||||
|
||||
if pmLoadResult.firstTime:
|
||||
@ -515,4 +515,5 @@ environment points to a valid, writable folder.""",
|
||||
else:
|
||||
return app
|
||||
|
||||
printBenchmark()
|
||||
if PROFILE_CODE:
|
||||
print_profile_results()
|
||||
|
Loading…
Reference in New Issue
Block a user