Marker#
- class composer.profiler.Marker(state, should_record, trace_handlers, name, record_instant_on_start, record_instant_on_finish, categories)[source]#
Profiler Marker.
Used by the
Engine
to measure the duration ofEvent
during training.Note
Marker
should not be instantiated directly; instead useProfiler.marker()
.Markers can record the following types of events:
Duration: Records the start and stop time of an event of interest (
Marker.start()
,Marker.finish()
).Instant: Record time a particular event occurs, but not the full duration (
Marker.instant()
).Counter: The value of a variable at given time (
Marker.counter()
).
A
Marker
can also be used as a context manager or decorator to record a duration:Use a
Marker
with a context manager:>>> def something_to_measure(): ... print("something_to_measure") >>> marker = profiler.marker("foo") >>> with marker: ... something_to_measure() something_to_measure
Use a
Marker
as a decorator:>>> marker = profiler.marker("foo") >>> @marker ... def something_to_measure(): ... print("something_to_measure") >>> something_to_measure() something_to_measure
- counter(values)[source]#
Record a counter event.
To record a counter event:
>>> marker = profiler.marker("foo") >>> counter_event = 5 >>> marker.counter({"counter_event": counter_event}) >>> counter_event = 10 >>> marker.counter({"counter_event": counter_event})
- finish()[source]#
Record the end of a duration event.
See
Marker.start()
for a usage example.
- instant()[source]#
Record an instant event.
To record an instant event:
>>> def something_to_measure(): ... print("something_to_measure") >>> marker = profiler.marker("instant") >>> marker.instant() >>> something_to_measure() something_to_measure
- start()[source]#
Record the start of a duration event.
To record the duration of an event, invoke
Marker.start()
followed byMarker.finish()
.>>> def something_to_measure(): ... print("something_to_measure") >>> marker = profiler.marker("foo") >>> marker.start() >>> something_to_measure() something_to_measure >>> marker.finish()