mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-04-19 16:49:02 +00:00
chore(core): move core/prof
into core/src/prof
It would allow interning profiling-related QSTRs in debug emulator builds. [no changelog]
This commit is contained in:
parent
04f9ada9bc
commit
c2dd63a6bd
@ -771,6 +771,9 @@ if FROZEN:
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/zcash_v4.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Zcash*.py'))
|
||||
|
||||
if PYOPT == '0':
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'prof/*.py'))
|
||||
|
||||
|
||||
source_mpy = env.FrozenModule(
|
||||
source=SOURCE_PY,
|
||||
|
@ -725,10 +725,13 @@ Q(DebugButton)
|
||||
Q(DebugPhysicalButton)
|
||||
Q(DebugSwipeDirection)
|
||||
Q(DebugWaitType)
|
||||
Q(__main__)
|
||||
Q(apps.debug)
|
||||
Q(apps.debug.load_device)
|
||||
Q(debug)
|
||||
Q(load_device)
|
||||
Q(prof)
|
||||
Q(prof.__main__)
|
||||
Q(storage.debug)
|
||||
Q(trezor.enums.DebugButton)
|
||||
Q(trezor.enums.DebugPhysicalButton)
|
||||
|
@ -13,6 +13,7 @@ PATTERNS = (
|
||||
"storage/**/*.py",
|
||||
"trezor/**/*.py",
|
||||
"apps/**/*.py",
|
||||
"prof/*.py",
|
||||
)
|
||||
|
||||
ALTCOINS = (
|
||||
@ -32,7 +33,7 @@ ALTCOINS = (
|
||||
|
||||
ALTCOINS_RE = re.compile("|".join(ALTCOINS), flags=re.IGNORECASE)
|
||||
THP_RE = re.compile(r"\.thp", flags=re.IGNORECASE)
|
||||
DEBUG_RE = re.compile("debug", flags=re.IGNORECASE)
|
||||
DEBUG_RE = re.compile("debug|prof", flags=re.IGNORECASE)
|
||||
|
||||
pyfiles = chain.from_iterable(sorted(SRCDIR.glob(p)) for p in PATTERNS)
|
||||
|
||||
|
@ -27,8 +27,6 @@ HERE = Path(__file__).resolve().parent
|
||||
MICROPYTHON = HERE / "build" / "unix" / "trezor-emu-core"
|
||||
SRC_DIR = HERE / "src"
|
||||
|
||||
PROFILING_WRAPPER = HERE / "prof" / "prof.py"
|
||||
|
||||
PROFILE_BASE = Path.home() / ".trezoremu"
|
||||
|
||||
TREZOR_STORAGE_FILES = (
|
||||
@ -205,7 +203,7 @@ def cli(
|
||||
raise click.ClickException("Cannot load mnemonics in production mode")
|
||||
|
||||
if profiling or alloc_profiling:
|
||||
main_args = [str(PROFILING_WRAPPER)]
|
||||
main_args = ["-m", "prof"]
|
||||
elif main:
|
||||
main_args = [main]
|
||||
else:
|
||||
|
@ -8,3 +8,4 @@ def mem_current() -> int: ...
|
||||
def mem_total() -> int: ...
|
||||
def mem_peak() -> int: ...
|
||||
def stack_use() -> int: ...
|
||||
def alloc_count() -> int: ...
|
||||
|
@ -1,4 +1,9 @@
|
||||
class FileIO: ...
|
||||
class FileIO:
|
||||
def __enter__(self) -> FileIO: ...
|
||||
|
||||
def __exit__(*args) -> None: ...
|
||||
|
||||
def write(self, data: bytes | str) -> int: ...
|
||||
|
||||
class StringIO:
|
||||
def __init__(self, _: Union[int, str]) -> None: ...
|
||||
|
0
core/src/prof/__init__.py
Normal file
0
core/src/prof/__init__.py
Normal file
@ -64,11 +64,10 @@ def _emulator_wrapper_main_args() -> list[str]:
|
||||
"""Look at TREZOR_PROFILING env variable, so that we can generate coverage reports."""
|
||||
do_profiling = os.environ.get("TREZOR_PROFILING") == "1"
|
||||
if do_profiling:
|
||||
core_dir = HERE.parent / "core"
|
||||
profiling_wrapper = core_dir / "prof" / "prof.py"
|
||||
src_dir = HERE.parent / "core" / "src"
|
||||
# So that the coverage reports have the correct paths
|
||||
os.environ["TREZOR_SRC"] = str(core_dir / "src")
|
||||
return [str(profiling_wrapper)]
|
||||
os.environ["TREZOR_SRC"] = str(src_dir)
|
||||
return ["-m", "prof"]
|
||||
else:
|
||||
return ["-m", "main"]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user