Repository: pytorch/ignite

Issue:
Error printing BasicTimeProfiler results
## 🐛 Bug description

Don't know if it's normal (because not yet stable feature) but using the following code : 
```
profiler = BasicTimeProfiler()
profiler.attach(trainer)
...
results = profiler.get_results()
print(results)
BasicTimeProfiler.print_results(profiler.get_results())
```
and I got a runtime error (I put here stack including print msg)
```
OrderedDict([('processing_stats', OrderedDict([('min/index', (0.002581869950518012, 937)), ('max/index', (0.24407817423343658, 0)), ('mean', 0.005071939900517464), ('std', 0.005763144697993994), ('total', 9.514959335327148)])), ('dataflow_stats', OrderedDict([('min/index', (5.4130003263708204e-05, 1874)), ('max/index', (0.02181326039135456, 1875)), ('mean', 0.00013960782962385565), ('std', 0.0006590772536583245), ('total', 0.2619042992591858)])), ('event_handlers_stats', {'EPOCH_STARTED': OrderedDict([('min/index', (6.137001037131995e-06, 0)), ('max/index', (1.3475997548084706e-05, 1)), ('mean', 9.80649929260835e-06), ('std', 5.189453986531589e-06), ('total', 1.96129985852167e-05)]), 'EPOCH_COMPLETED': OrderedDict([('min/index', (3.951500654220581, 0)), ('max/index', (4.009259223937988, 1)), ('mean', 3.980380058288574), ('std', 0.0408414751291275), ('total', 7.960760116577148)]), 'STARTED': OrderedDict([('min/index', (4.647001333069056e-06, 0)), ('max/index', (4.647001333069056e-06, 0)), ('mean', 4.647001333069056e-06), ('std', nan), ('total', 4.647001333069056e-06)]), 'COMPLETED': OrderedDict([('min/index', (0.001252603018656373, 0)), ('max/index', (0.001252603018656373, 0)), ('mean', 0.001252603018656373), ('std', nan), ('total', 0.001252603018656373)]), 'ITERATION_STARTED': OrderedDict([('min/index', (1.2870004866272211e-06, 931)), ('max/index', (1.6206002328544855e-05, 784)), ('mean', 2.0810284695471637e-06), ('std', 1.0310620837117312e-06), ('total', 0.003904009470716119)]), 'ITERATION_COMPLETED': OrderedDict([('min/index', (0.00041244301246479154, 6)), ('max/index', (0.0033979369327425957, 1706)), ('mean', 0.0005990439676679671), ('std', 0.00017004708934109658), ('total', 1.1238064765930176)]), 'GET_BATCH_STARTED': OrderedDict([('min/index', (2.2699969122186303e-06, 1871)), ('max/index', (6.306700379354879e-05, 1627)), ('mean', 3.619041763158748e-06), ('std', 2.3099164536688477e-06), ('total', 0.006789322476834059)]), 'GET_BATCH_COMPLETED': OrderedDict([('min/index', (1.471998984925449e-06, 934)), ('max/index', (1.4063996786717325e-05, 918)), ('mean', 2.3078853246261133e-06), ('std', 8.762469292378228e-07), ('total', 0.0043295929208397865)]), 'total_time': tensor(9.1009)}), ('event_handlers_names', {'EPOCH_STARTED_names': ['Metric.started'], 'EPOCH_COMPLETED_names': ['ProgressBar._close', 'log_training_results_fn', 'log_validation_results_fn'], 'STARTED_names': ['BasicTimeProfiler._as_first_started'], 'COMPLETED_names': ['ModelCheckpoint'], 'ITERATION_STARTED_names': [], 'ITERATION_COMPLETED_names': ['Metric.iteration_completed', 'Metric.completed', 'LRScheduler', '_OutputHandler', 'Engine._handler_wrapper.<locals>.wrapper', 'Engine._handler_wrapper.<locals>.wrapper'], 'GET_BATCH_STARTED_names': [], 'GET_BATCH_COMPLETED_names': []})])
Traceback (most recent call last):
  File "tutorials/mnist/mnist.py", line 228, in <module>
    BasicTimeProfiler.print_results(profiler.get_results())
  File "/work/desrozis/Softwares/conda/envs/focus-light/lib/python3.7/site-packages/ignite/contrib/handlers/time_profilers.py", line 414, in print_results
    **others,
KeyError: 'Events_STARTED'
```
There is no key `Events_STARTED` and more generaly no one begins with the `Events_` prefix. Did I miss something ? Or is it the `output_message` variable in the `time_profilers.py` file which is corrupted ?

Thanks for your help !

## Environment

 - PyTorch Version (e.g., 1.4): 1.4
 - Ignite Version (e.g., 0.3.0): master
 - OS (e.g., Linux): Linux
 - How you installed Ignite (`conda`, `pip`, source): pip from sources 
 - Python version: 3.7
 - Any other relevant information: git tag 4dced08f4ee294c36f54c4c64c7d60adb6aefc72



Discussion:

Patch:
diff --git a/ignite/contrib/handlers/time_profilers.py b/ignite/contrib/handlers/time_profilers.py
index 4a4537d0..41c6d6d5 100644
--- a/ignite/contrib/handlers/time_profilers.py
+++ b/ignite/contrib/handlers/time_profilers.py
@@ -379,34 +379,34 @@ Time stats of event handlers (in seconds):
 \t{total_time}
 
 - Events.STARTED:
-{Events_STARTED}
+{STARTED}
 Handlers names:
-{Events_STARTED_names}
+{STARTED_names}
 
 - Events.EPOCH_STARTED:
-{Events_EPOCH_STARTED}
+{EPOCH_STARTED}
 Handlers names:
-{Events_EPOCH_STARTED_names}
+{EPOCH_STARTED_names}
 
 - Events.ITERATION_STARTED:
-{Events_ITERATION_STARTED}
+{ITERATION_STARTED}
 Handlers names:
-{Events_ITERATION_STARTED_names}
+{ITERATION_STARTED_names}
 
 - Events.ITERATION_COMPLETED:
-{Events_ITERATION_COMPLETED}
+{ITERATION_COMPLETED}
 Handlers names:
-{Events_ITERATION_COMPLETED_names}
+{ITERATION_COMPLETED_names}
 
 - Events.EPOCH_COMPLETED:
-{Events_EPOCH_COMPLETED}
+{EPOCH_COMPLETED}
 Handlers names:
-{Events_EPOCH_COMPLETED_names}
+{EPOCH_COMPLETED_names}
 
 - Events.COMPLETED:
-{Events_COMPLETED}
+{COMPLETED}
 Handlers names:
-{Events_COMPLETED_names}
+{COMPLETED_names}
 
 """.format(
             processing_stats=odict_to_str(results["processing_stats"]),


Test patch:
diff --git a/tests/ignite/contrib/handlers/test_time_profilers.py b/tests/ignite/contrib/handlers/test_time_profilers.py
index 7f1f5678..039bea05 100644
--- a/tests/ignite/contrib/handlers/test_time_profilers.py
+++ b/tests/ignite/contrib/handlers/test_time_profilers.py
@@ -358,3 +358,26 @@ def test_write_results():
 
     # cleanup test log directory
     shutil.rmtree(test_folder)
+
+
+def test_print_results(capsys):
+    true_event_handler_time = 0.
+    true_max_epochs = 1
+    true_num_iters = 1
+
+    profiler = BasicTimeProfiler()
+    dummy_trainer = Engine(_do_nothing_update_fn)
+    profiler.attach(dummy_trainer)
+
+    @dummy_trainer.on(Events.GET_BATCH_COMPLETED)
+    def delay_get_batch_completed(engine):
+        time.sleep(true_event_handler_time)
+
+    dummy_trainer.run(range(true_num_iters), max_epochs=true_max_epochs)
+    results = profiler.get_results()
+    BasicTimeProfiler.print_results(profiler.get_results())
+
+    captured = capsys.readouterr()
+    out = captured.out
+
+    assert out[0] == "\n"