Пример #1
0
 def _end_session(self):
   url = profiler.stop()
   if url is not None:
     platform.work_unit().create_artifact(
         platform.ArtifactType.URL,
         url,
         description=f"[{self._previous_step}] Profile")
   self._session_running = False
Пример #2
0
 def _should_trigger(self, step: int, t: float) -> bool:
     if self._session_running:
         # If a session is running we only check if we should stop it.
         dt = t - self._session_started
         cond = (not self._profile_duration_ms
                 or dt * 1e3 >= self._profile_duration_ms)
         cond &= (not self._num_profile_steps
                  or step >= self._previous_step + self._num_profile_steps)
         if cond:
             self._end_session(profiler.stop())
             return False
     # Allow triggering at `self._first_profile` step.
     return super()._should_trigger(step, t) or step == self._first_profile
Пример #3
0
 def _apply_condition(self, step: int, t: float) -> bool:
   if self._session_running:
     dt = time.time() - self._session_started
     cond = (not self._profile_duration_ms or
             dt * 1e3 >= self._profile_duration_ms)
     cond &= (not self._num_profile_steps or
              step >= self._previous_step + self._num_profile_steps)
     if cond:
       self._end_session(profiler.stop())
       return False
   if step == self._first_profile:
     return True
   return super()._apply_condition(step, t)