MCPcopy
hub / github.com/NVIDIA-NeMo/RL / stop

Method stop

nemo_rl/utils/timer.py:85–107  ·  view source on GitHub ↗

Stop timing for the given label and return the elapsed time. Args: label: The label to stop timing for Returns: The elapsed time in seconds Raises: ValueError: If the timer for the given label is not running

(self, label: str)

Source from the content-addressed store, hash-verified

83 self._start_times[label] = time.perf_counter()
84
85 def stop(self, label: str) -> float:
86 """Stop timing for the given label and return the elapsed time.
87
88 Args:
89 label: The label to stop timing for
90
91 Returns:
92 The elapsed time in seconds
93
94 Raises:
95 ValueError: If the timer for the given label is not running
96 """
97 if label not in self._start_times:
98 raise ValueError(
99 f"Timer '{label}' is not running. Running times: {self._start_times.keys()}"
100 )
101
102 elapsed = time.perf_counter() - self._start_times[label]
103 if label not in self._timers:
104 self._timers[label] = []
105 self._timers[label].append(elapsed)
106 del self._start_times[label]
107 return elapsed
108
109 @contextmanager
110 def time(self, label: str) -> Generator[None, None, None]:

Callers 6

run_rolloutsMethod · 0.95
timeMethod · 0.95
stop_gpu_profilingMethod · 0.45
stop_gpu_profilingMethod · 0.45
stop_gpu_profilingMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected