Skip to content

Commit

Permalink
Cleanup new profiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
J08nY committed Jul 15, 2024
1 parent d71a021 commit 73e3bf1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@


class RawTimer:
start: int
end: int
duration: float

def __enter__(self):
self.start = time.perf_counter_ns()

Expand All @@ -20,8 +24,17 @@ def __exit__(self, exc_type, exc_val, exc_tb):


class Profiler:
def __init__(self, prof_type: Union[Literal["py"], Literal["c"], Literal["raw"]], output_directory: str, benchmark_name: str):
self._prof: Union[PyProfiler, cProfiler, RawTimer] = {"py": PyProfiler, "c": cProfiler, "raw": RawTimer}[prof_type]()
def __init__(
self,
prof_type: Union[Literal["py"], Literal["c"], Literal["raw"]],
output_directory: str,
benchmark_name: str,
):
self._prof: Union[PyProfiler, cProfiler, RawTimer] = {
"py": PyProfiler,
"c": cProfiler,
"raw": RawTimer,
}[prof_type]()
self._prof_type: Union[Literal["py"], Literal["c"], Literal["raw"]] = prof_type
self._root_frame = None
self._state = "out"
Expand Down

0 comments on commit 73e3bf1

Please sign in to comment.