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
|
||||
|
||||
|
||||
def printBenchmark(argumentsNamespace, profiller):
|
||||
if argumentsNamespace.benchmark and profiller:
|
||||
def printBenchmark(argumentsNamespace, profiler):
|
||||
if argumentsNamespace.benchmark and profiler:
|
||||
import io
|
||||
import pstats
|
||||
|
||||
profiller.disable()
|
||||
profiler.disable()
|
||||
outputstream = io.StringIO()
|
||||
profiller_status = pstats.Stats(profiller, stream=outputstream)
|
||||
profiller_status.sort_stats("time")
|
||||
profiller_status.print_stats()
|
||||
sys.stderr.write(
|
||||
f"\n{outputstream.getvalue()[:argumentsNamespace.benchmark]}\n"
|
||||
)
|
||||
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 +390,7 @@ def _run(argv=None, exec=True):
|
|||
If no 'argv' is supplied then 'sys.argv' will be used.
|
||||
"""
|
||||
global mw
|
||||
profiller = None
|
||||
profiler = None
|
||||
|
||||
if argv is None:
|
||||
argv = sys.argv
|
||||
|
@ -403,8 +401,8 @@ def _run(argv=None, exec=True):
|
|||
if opts.benchmark:
|
||||
import cProfile
|
||||
|
||||
profiller = cProfile.Profile()
|
||||
profiller.enable()
|
||||
profiler = cProfile.Profile()
|
||||
profiler.enable()
|
||||
|
||||
# profile manager
|
||||
pm = None
|
||||
|
@ -438,7 +436,7 @@ def _run(argv=None, exec=True):
|
|||
app = AnkiApp(argv)
|
||||
if app.secondInstance():
|
||||
# we've signaled the primary instance, so we should close
|
||||
printBenchmark(opts, profiller)
|
||||
printBenchmark(opts, profiler)
|
||||
return
|
||||
|
||||
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 \
|
||||
section of the manual, and ensure that location is not read-only.""",
|
||||
)
|
||||
printBenchmark(opts, profiller)
|
||||
printBenchmark(opts, profiler)
|
||||
return
|
||||
|
||||
# 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 \
|
||||
environment points to a valid, writable folder.""",
|
||||
)
|
||||
printBenchmark(opts, profiller)
|
||||
printBenchmark(opts, profiler)
|
||||
return
|
||||
|
||||
if pmLoadResult.firstTime:
|
||||
|
@ -522,7 +520,7 @@ environment points to a valid, writable folder.""",
|
|||
if exec:
|
||||
app.exec()
|
||||
else:
|
||||
printBenchmark(opts, profiller)
|
||||
printBenchmark(opts, profiler)
|
||||
return app
|
||||
|
||||
printBenchmark(opts, profiller)
|
||||
printBenchmark(opts, profiler)
|
||||
|
|
Loading…
Reference in a new issue