Shortcuts

HandlersTimeProfiler#

class ignite.handlers.time_profilers.HandlersTimeProfiler[source]#

HandlersTimeProfiler can be used to profile the handlers, data loading and data processing times. Custom events are also profiled by this profiler

Examples

from ignite.handlers import HandlersTimeProfiler

trainer = Engine(train_updater)

# Create an object of the profiler and attach an engine to it
profiler = HandlersTimeProfiler()
profiler.attach(trainer)

@trainer.on(Events.EPOCH_COMPLETED)
def log_intermediate_results():
    profiler.print_results(profiler.get_results())

trainer.run(dataloader, max_epochs=3)

profiler.write_results('path_to_dir/time_profiling.csv')

New in version 0.4.6.

Methods

attach

Attach HandlersTimeProfiler to the given engine.

get_results

Method to fetch the aggregated profiler results after the engine is run

print_results

Method to print the aggregated results from the profiler

write_results

Method to store the unaggregated profiling results to a csv file

attach(engine)[source]#

Attach HandlersTimeProfiler to the given engine.

Parameters

engine (Engine) – the instance of Engine to attach

Return type

None

get_results()[source]#

Method to fetch the aggregated profiler results after the engine is run

results = profiler.get_results()
Return type

List[List[Union[str, float]]]

static print_results(results)[source]#

Method to print the aggregated results from the profiler

Parameters

results (List[List[Union[str, float]]]) – the aggregated results from the profiler

Return type

None

profiler.print_results(results)

Examples

-----------------------------------------  -----------------------  -------------- ...
Handler                                    Event Name                     Total(s)
-----------------------------------------  -----------------------  --------------
run.<locals>.log_training_results          EPOCH_COMPLETED                19.43245
run.<locals>.log_validation_results        EPOCH_COMPLETED                 2.55271
run.<locals>.log_time                      EPOCH_COMPLETED                 0.00049
run.<locals>.log_intermediate_results      EPOCH_COMPLETED                 0.00106
run.<locals>.log_training_loss             ITERATION_COMPLETED               0.059
run.<locals>.log_time                      COMPLETED                 not triggered
-----------------------------------------  -----------------------  --------------
Total                                                                     22.04571
-----------------------------------------  -----------------------  --------------
Processing took total 11.29543s [min/index: 0.00393s/1875, max/index: 0.00784s/0,
 mean: 0.00602s, std: 0.00034s]
Dataflow took total 16.24365s [min/index: 0.00533s/1874, max/index: 0.01129s/937,
 mean: 0.00866s, std: 0.00113s]
write_results(output_path)[source]#

Method to store the unaggregated profiling results to a csv file

Parameters

output_path (str) – file output path containing a filename

Return type

None

profiler.write_results('path_to_dir/awesome_filename.csv')

Examples

-----------------------------------------------------------------
# processing_stats dataflow_stats training.<locals>.log_elapsed_time (EPOCH_COMPLETED) ...
1     0.00003         0.252387                          0.125676
2     0.00029         0.252342                          0.125123