Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hyperwall/macos_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
)
_THERMAL_RE = re.compile(r"^Current pressure level:\s*(?P<level>\S.*)\s*$")
_GPU_IDLE_RE = re.compile(r"^GPU idle residency:\s*(?P<idle>[0-9]+(?:\.[0-9]+)?)%")
_THREAD_RE = re.compile(r"^\s*Thread\b")
_THREAD_RE = re.compile(r"^\s*(?:\d+\s+)?Thread(?:[_\s]|$)")
_PERMISSION_MARKERS = (
"must be invoked as the superuser",
"not permitted",
Expand Down
20 changes: 20 additions & 0 deletions tests/test_macos_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,26 @@ def test_sample_parser_counts_native_hot_stack_labels():
assert report["labels"]["_PyEval_EvalFrameDefault"] == 1


def test_sample_parser_accepts_macos_thread_rows_with_numeric_prefix():
from hyperwall.macos_profile import parse_sample_stacks

sample = """\
Process: Python [75185]
Call graph:
2930 Thread_1168979 DispatchQueue_1: com.apple.main-thread (serial)
+ 2930 _PyEval_EvalFrameDefault (in Python) + 10488
265 Thread_1168991
+ 1 libmpv.2.dylib mpv_render_context_render
"""

report = parse_sample_stacks(sample)

assert report["complete"] is True
assert report["thread_count"] == 2
assert report["labels"]["_PyEval_EvalFrameDefault"] == 1
assert report["labels"]["mpv_render_context_render"] == 1


def test_sample_parser_marks_empty_capture_incomplete():
from hyperwall.macos_profile import parse_sample_stacks

Expand Down
Loading