mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-08 04:24:47 +00:00
[profiler] primary memory tracer
This commit is contained in:
@@ -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.
|
||||
|
||||
|
Reference in New Issue
Block a user