mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Merge pull request #836 from abdnh/fix-profiler
Fix UnboundLocalError in profiler code
This commit is contained in:
commit
fa826d076e
1 changed files with 2 additions and 4 deletions
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import builtins
|
import builtins
|
||||||
|
import cProfile
|
||||||
import getpass
|
import getpass
|
||||||
import locale
|
import locale
|
||||||
import os
|
import os
|
||||||
|
@ -38,7 +39,7 @@ appHelpSite = HELP_SITE
|
||||||
from aqt.main import AnkiQt # isort:skip
|
from aqt.main import AnkiQt # isort:skip
|
||||||
from aqt.profiles import ProfileManager, AnkiRestart # isort:skip
|
from aqt.profiles import ProfileManager, AnkiRestart # isort:skip
|
||||||
|
|
||||||
profiler = None
|
profiler: Optional[cProfile.Profile] = None
|
||||||
mw: Optional[AnkiQt] = None # set on init
|
mw: Optional[AnkiQt] = None # set on init
|
||||||
|
|
||||||
moduleDir = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
|
moduleDir = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
|
||||||
|
@ -387,9 +388,7 @@ PROFILE_CODE = os.environ.get("ANKI_PROFILE_CODE")
|
||||||
|
|
||||||
|
|
||||||
def write_profile_results():
|
def write_profile_results():
|
||||||
import cProfile
|
|
||||||
|
|
||||||
profiler: cProfile.Profile
|
|
||||||
profiler.disable()
|
profiler.disable()
|
||||||
profiler.dump_stats("anki.prof")
|
profiler.dump_stats("anki.prof")
|
||||||
print("profile stats written to anki.prof")
|
print("profile stats written to anki.prof")
|
||||||
|
@ -431,7 +430,6 @@ def _run(argv=None, exec=True):
|
||||||
return
|
return
|
||||||
|
|
||||||
if PROFILE_CODE:
|
if PROFILE_CODE:
|
||||||
import cProfile
|
|
||||||
|
|
||||||
profiler = cProfile.Profile()
|
profiler = cProfile.Profile()
|
||||||
profiler.enable()
|
profiler.enable()
|
||||||
|
|
Loading…
Reference in a new issue