From eea57d6019d7b13a3c9e01cf1ecb11b132e5e291 Mon Sep 17 00:00:00 2001 From: J08nY Date: Tue, 16 Jul 2024 16:33:26 +0200 Subject: Better print in perf. --- test/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test/utils.py') diff --git a/test/utils.py b/test/utils.py index 5d1e80f..1276ad6 100644 --- a/test/utils.py +++ b/test/utils.py @@ -29,6 +29,7 @@ class Profiler: prof_type: Union[Literal["py"], Literal["c"], Literal["raw"]], output_directory: str, benchmark_name: str, + operations: int = 0 ): self._prof: Union[PyProfiler, cProfiler, RawTimer] = { "py": PyProfiler, @@ -40,6 +41,7 @@ class Profiler: self._state = "out" self._output_directory = output_directory self._benchmark_name = benchmark_name + self._operations = operations def __enter__(self): self._prof.__enter__() @@ -90,7 +92,7 @@ class Profiler: elif self._prof_type == "c": self._prof.print_stats("cumtime") # type: ignore elif self._prof_type == "raw": - print(f"{self._prof.duration:.4} s") # type: ignore + print(f"{self._prof.duration:.4f}s {(self._operations/self._prof.duration) if self._operations else '-':.1f}op/s") # type: ignore def get_time(self) -> float: if self._state != "out": -- cgit v1.2.3-70-g09d2