From 2e11a596aa4bb7ee4f6e68cb5a2e13a10fc444c4 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Mon, 4 May 2020 23:15:23 -0300 Subject: [PATCH] Fixed profiler word misspelling and stopped trimming the output --- qt/aqt/__init__.py | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/qt/aqt/__init__.py b/qt/aqt/__init__.py index 5637c69fe..1c440c726 100644 --- a/qt/aqt/__init__.py +++ b/qt/aqt/__init__.py @@ -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)