Handler for Ignite Engine classes which measures the time from a start event ton an end event. This can be used to profile epoch, iteration, and other events as defined in `ignite.engine.Events`. This class should be used only within the context of a profiler object. Args:
| 399 | |
| 400 | |
| 401 | class ProfileHandler: |
| 402 | """ |
| 403 | Handler for Ignite Engine classes which measures the time from a start event ton an end event. This can be used to |
| 404 | profile epoch, iteration, and other events as defined in `ignite.engine.Events`. This class should be used only |
| 405 | within the context of a profiler object. |
| 406 | |
| 407 | Args: |
| 408 | name: name of event to profile |
| 409 | profiler: instance of WorkflowProfiler used by the handler, should be within the context of this object |
| 410 | start_event: item in `ignite.engine.Events` stating event at which to start timing |
| 411 | end_event: item in `ignite.engine.Events` stating event at which to stop timing |
| 412 | """ |
| 413 | |
| 414 | def __init__(self, name: str, profiler: WorkflowProfiler, start_event: Events, end_event: Events): |
| 415 | self.name = name |
| 416 | self.profiler = profiler |
| 417 | self.start_event = start_event |
| 418 | self.end_event = end_event |
| 419 | self.ctx: Any = None |
| 420 | |
| 421 | def attach(self, engine): |
| 422 | engine.add_event_handler(self.start_event, self.start) |
| 423 | engine.add_event_handler(self.end_event, self.end) |
| 424 | return self |
| 425 | |
| 426 | def start(self, engine): |
| 427 | self.ctx = self.profiler.profile_ctx(self.name) |
| 428 | self.ctx.__enter__() |
| 429 | |
| 430 | def end(self, engine): |
| 431 | self.ctx.__exit__(None, None, None) |
| 432 | self.ctx = None |
no outgoing calls
searching dependent graphs…