diff --git a/src/akarsu/akarsu.py b/src/akarsu/akarsu.py index 005e33c..886e30b 100644 --- a/src/akarsu/akarsu.py +++ b/src/akarsu/akarsu.py @@ -1,3 +1,4 @@ +import re import sys import types from typing import Any, Final, cast @@ -20,6 +21,7 @@ (EVENTS.STOP_ITERATION, "STOP ITERATION"), ) EVENT_SET: Final[int] = EVENTS.CALL + sum(ev for ev, _ in TRACKED_EVENTS) +PATTERN: Final[str] = r" at 0x[0-9a-f]+" class Akarsu: @@ -27,6 +29,10 @@ def __init__(self, code: str, file_name: str) -> None: self.code = code self.file_name = file_name + def format_func_name(self, event: tuple[str, str, str]) -> tuple[str, str, str]: + event_type, file_name, func_name = event + return (event_type, file_name, re.sub(PATTERN, "", func_name)) + def profile(self) -> list[tuple[str, str, str]]: events = [] @@ -64,6 +70,10 @@ def record_call( MONITOR.set_events(TOOL, 0) MONITOR.free_tool_id(TOOL) - events = [e for e in events[2:-3] if "____wrapper____" not in e[2]] + events = [ + self.format_func_name(event) + for event in events[2:-3] + if "____wrapper____" not in event[2] + ] return events