[profiler] primary memory tracer

This commit is contained in:
Jie Zhu
2022-03-04 09:35:23 +08:00
committed by Frank Lee
parent dfc3fafe89
commit d344689274
4 changed files with 93 additions and 19 deletions

View File

@@ -19,6 +19,11 @@ class Timer:
def has_history(self):
return len(self._history) != 0
@property
def current_time(self) -> float:
synchronize()
return time.time()
def start(self):
"""Fisrtly synchronize cuda, reset the clock and then start the timer.
"""
@@ -27,6 +32,11 @@ class Timer:
self._start_time = time.time()
self._started = True
def lap(self):
"""lap time and return elapsed time
"""
return self.current_time - self._start_time
def stop(self, keep_in_history: bool = False):
"""Stop the timer and record the start-stop time interval.