mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Fixed profiler word misspelling and stopped trimming the output
This commit is contained in:
parent
b63bfc83d8
commit
2e11a596aa
1 changed files with 15 additions and 17 deletions
|
@ -354,19 +354,17 @@ def setupGL(pm):
|
||||||
os.environ["QT_OPENGL"] = mode
|
os.environ["QT_OPENGL"] = mode
|
||||||
|
|
||||||
|
|
||||||
def printBenchmark(argumentsNamespace, profiller):
|
def printBenchmark(argumentsNamespace, profiler):
|
||||||
if argumentsNamespace.benchmark and profiller:
|
if argumentsNamespace.benchmark and profiler:
|
||||||
import io
|
import io
|
||||||
import pstats
|
import pstats
|
||||||
|
|
||||||
profiller.disable()
|
profiler.disable()
|
||||||
outputstream = io.StringIO()
|
outputstream = io.StringIO()
|
||||||
profiller_status = pstats.Stats(profiller, stream=outputstream)
|
profiler_status = pstats.Stats(profiler, stream=outputstream)
|
||||||
profiller_status.sort_stats("time")
|
profiler_status.sort_stats("time")
|
||||||
profiller_status.print_stats()
|
profiler_status.print_stats()
|
||||||
sys.stderr.write(
|
sys.stderr.write(f"\n{outputstream.getvalue()}\n")
|
||||||
f"\n{outputstream.getvalue()[:argumentsNamespace.benchmark]}\n"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
@ -392,7 +390,7 @@ def _run(argv=None, exec=True):
|
||||||
If no 'argv' is supplied then 'sys.argv' will be used.
|
If no 'argv' is supplied then 'sys.argv' will be used.
|
||||||
"""
|
"""
|
||||||
global mw
|
global mw
|
||||||
profiller = None
|
profiler = None
|
||||||
|
|
||||||
if argv is None:
|
if argv is None:
|
||||||
argv = sys.argv
|
argv = sys.argv
|
||||||
|
@ -403,8 +401,8 @@ def _run(argv=None, exec=True):
|
||||||
if opts.benchmark:
|
if opts.benchmark:
|
||||||
import cProfile
|
import cProfile
|
||||||
|
|
||||||
profiller = cProfile.Profile()
|
profiler = cProfile.Profile()
|
||||||
profiller.enable()
|
profiler.enable()
|
||||||
|
|
||||||
# profile manager
|
# profile manager
|
||||||
pm = None
|
pm = None
|
||||||
|
@ -438,7 +436,7 @@ def _run(argv=None, exec=True):
|
||||||
app = AnkiApp(argv)
|
app = AnkiApp(argv)
|
||||||
if app.secondInstance():
|
if app.secondInstance():
|
||||||
# we've signaled the primary instance, so we should close
|
# we've signaled the primary instance, so we should close
|
||||||
printBenchmark(opts, profiller)
|
printBenchmark(opts, profiler)
|
||||||
return
|
return
|
||||||
|
|
||||||
if not pm:
|
if not pm:
|
||||||
|
@ -449,7 +447,7 @@ def _run(argv=None, exec=True):
|
||||||
Anki could not create its data folder. Please see the File Locations \
|
Anki could not create its data folder. Please see the File Locations \
|
||||||
section of the manual, and ensure that location is not read-only.""",
|
section of the manual, and ensure that location is not read-only.""",
|
||||||
)
|
)
|
||||||
printBenchmark(opts, profiller)
|
printBenchmark(opts, profiler)
|
||||||
return
|
return
|
||||||
|
|
||||||
# disable icons on mac; this must be done before window created
|
# disable icons on mac; this must be done before window created
|
||||||
|
@ -483,7 +481,7 @@ 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 \
|
No usable temporary folder found. Make sure C:\\temp exists or TEMP in your \
|
||||||
environment points to a valid, writable folder.""",
|
environment points to a valid, writable folder.""",
|
||||||
)
|
)
|
||||||
printBenchmark(opts, profiller)
|
printBenchmark(opts, profiler)
|
||||||
return
|
return
|
||||||
|
|
||||||
if pmLoadResult.firstTime:
|
if pmLoadResult.firstTime:
|
||||||
|
@ -522,7 +520,7 @@ environment points to a valid, writable folder.""",
|
||||||
if exec:
|
if exec:
|
||||||
app.exec()
|
app.exec()
|
||||||
else:
|
else:
|
||||||
printBenchmark(opts, profiller)
|
printBenchmark(opts, profiler)
|
||||||
return app
|
return app
|
||||||
|
|
||||||
printBenchmark(opts, profiller)
|
printBenchmark(opts, profiler)
|
||||||
|
|
Loading…
Reference in a new issue