mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-08-04 04:48:48 +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 + 'apps/bitcoin/sign_tx/zcash_v4.py'))
|
||||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Zcash*.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_mpy = env.FrozenModule(
|
||||||
source=SOURCE_PY,
|
source=SOURCE_PY,
|
||||||
|
@ -725,10 +725,13 @@ Q(DebugButton)
|
|||||||
Q(DebugPhysicalButton)
|
Q(DebugPhysicalButton)
|
||||||
Q(DebugSwipeDirection)
|
Q(DebugSwipeDirection)
|
||||||
Q(DebugWaitType)
|
Q(DebugWaitType)
|
||||||
|
Q(__main__)
|
||||||
Q(apps.debug)
|
Q(apps.debug)
|
||||||
Q(apps.debug.load_device)
|
Q(apps.debug.load_device)
|
||||||
Q(debug)
|
Q(debug)
|
||||||
Q(load_device)
|
Q(load_device)
|
||||||
|
Q(prof)
|
||||||
|
Q(prof.__main__)
|
||||||
Q(storage.debug)
|
Q(storage.debug)
|
||||||
Q(trezor.enums.DebugButton)
|
Q(trezor.enums.DebugButton)
|
||||||
Q(trezor.enums.DebugPhysicalButton)
|
Q(trezor.enums.DebugPhysicalButton)
|
||||||
|
@ -13,6 +13,7 @@ PATTERNS = (
|
|||||||
"storage/**/*.py",
|
"storage/**/*.py",
|
||||||
"trezor/**/*.py",
|
"trezor/**/*.py",
|
||||||
"apps/**/*.py",
|
"apps/**/*.py",
|
||||||
|
"prof/*.py",
|
||||||
)
|
)
|
||||||
|
|
||||||
ALTCOINS = (
|
ALTCOINS = (
|
||||||
@ -32,7 +33,7 @@ ALTCOINS = (
|
|||||||
|
|
||||||
ALTCOINS_RE = re.compile("|".join(ALTCOINS), flags=re.IGNORECASE)
|
ALTCOINS_RE = re.compile("|".join(ALTCOINS), flags=re.IGNORECASE)
|
||||||
THP_RE = re.compile(r"\.thp", 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)
|
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"
|
MICROPYTHON = HERE / "build" / "unix" / "trezor-emu-core"
|
||||||
SRC_DIR = HERE / "src"
|
SRC_DIR = HERE / "src"
|
||||||
|
|
||||||
PROFILING_WRAPPER = HERE / "prof" / "prof.py"
|
|
||||||
|
|
||||||
PROFILE_BASE = Path.home() / ".trezoremu"
|
PROFILE_BASE = Path.home() / ".trezoremu"
|
||||||
|
|
||||||
TREZOR_STORAGE_FILES = (
|
TREZOR_STORAGE_FILES = (
|
||||||
@ -205,7 +203,7 @@ def cli(
|
|||||||
raise click.ClickException("Cannot load mnemonics in production mode")
|
raise click.ClickException("Cannot load mnemonics in production mode")
|
||||||
|
|
||||||
if profiling or alloc_profiling:
|
if profiling or alloc_profiling:
|
||||||
main_args = [str(PROFILING_WRAPPER)]
|
main_args = ["-m", "prof"]
|
||||||
elif main:
|
elif main:
|
||||||
main_args = [main]
|
main_args = [main]
|
||||||
else:
|
else:
|
||||||
|
@ -8,3 +8,4 @@ def mem_current() -> int: ...
|
|||||||
def mem_total() -> int: ...
|
def mem_total() -> int: ...
|
||||||
def mem_peak() -> int: ...
|
def mem_peak() -> int: ...
|
||||||
def stack_use() -> 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:
|
class StringIO:
|
||||||
def __init__(self, _: Union[int, str]) -> None: ...
|
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."""
|
"""Look at TREZOR_PROFILING env variable, so that we can generate coverage reports."""
|
||||||
do_profiling = os.environ.get("TREZOR_PROFILING") == "1"
|
do_profiling = os.environ.get("TREZOR_PROFILING") == "1"
|
||||||
if do_profiling:
|
if do_profiling:
|
||||||
core_dir = HERE.parent / "core"
|
src_dir = HERE.parent / "core" / "src"
|
||||||
profiling_wrapper = core_dir / "prof" / "prof.py"
|
|
||||||
# So that the coverage reports have the correct paths
|
# So that the coverage reports have the correct paths
|
||||||
os.environ["TREZOR_SRC"] = str(core_dir / "src")
|
os.environ["TREZOR_SRC"] = str(src_dir)
|
||||||
return [str(profiling_wrapper)]
|
return ["-m", "prof"]
|
||||||
else:
|
else:
|
||||||
return ["-m", "main"]
|
return ["-m", "main"]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user