TraceHandler#
- class composer.profiler.TraceHandler(*args, **kwargs)[source]#
Base class for Composer Profiler trace handlers.
Subclasses should implement
process_duration_event()
,process_instant_event()
,process_counter_event()
, andprocess_chrome_json_trace_file()
to record trace events.Since
TraceHandler
subclassesCallback
, a trace handler can run on anyEvent
(such as onEvent.INIT
to open files or onEvent.BATCH_END
to periodically dump data to files) and useCallback.close()
to perform any cleanup.- process_chrome_json_trace_file(filepath)[source]#
Invoked when there are events in Chrome JSON format to record.
See this document for more information.
- Parameters
filepath (Path) โ The filepath to a Chrome JSON trace file.
- process_counter_event(name, categories, timestamp, wall_clock_time_ns, values)[source]#
Invoked whenever there is an counter event to record.
- Parameters
name (str) โ The name of the event.
categories (List[str] | Tuple[str, ...]) โ The categories for the event.
timestamp (Timestamp) โ The timestamp.
wall_clock_time_ns (int) โ The
time.time_ns()
corresponding to the event.values (Dict[str, int | float]) โ The values corresponding to this counter event.
- process_duration_event(name, categories, is_start, timestamp, wall_clock_time_ns)[source]#
Invoked whenever there is a duration event to record.
This method is called twice for each duration event โ once with
is_start = True
, and then again withis_start = False
. Interleaving events are not permitted. Specifically, for each event (identified by thename
), a call withis_start = True
will be followed by a call withis_start = False
before another call withis_start = True
.- Parameters
name (str) โ The name of the event.
categories (Union[List[str], Tuple[str, ...]]) โ The categories for the event.
is_start (bool) โ Whether the event is a start event or end event.
timestamp (Timestamp) โ Snapshot of the training time.
wall_clock_time_ns (int) โ The
time.time_ns()
corresponding to the event.