Skip to content

Commit 473d1e8

Browse files
committed
[ExecuteTime] Optionally clear all timing data on kernel restart
1 parent f106638 commit 473d1e8

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/jupyter_contrib_nbextensions/nbextensions/execute_time/ExecuteTime.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ define([
3333

3434
// defaults, overridden by server's config
3535
var options = {
36+
clear_timings_on_kernel_restart: false,
3637
default_kernel_to_utc: true,
3738
display_absolute_format: 'HH:mm:ss YYYY-MM-DD',
3839
display_absolute_timings: true,
@@ -313,6 +314,12 @@ define([
313314
update_all_timing_areas();
314315
}
315316

317+
// setup optional clear-data calls
318+
if (options.clear_timings_on_kernel_restart) {
319+
console.log(log_prefix, 'Binding kernel_restarting.Kernel event to clear timings.');
320+
events.on('kernel_restarting.Kernel', clear_timing_data_all);
321+
}
322+
316323
// if displaying relative times, update them at intervals
317324
if (!options.display_absolute_timings) {
318325
var period_ms = 1000 * Math.max(1, options.relative_timing_update_period);

src/jupyter_contrib_nbextensions/nbextensions/execute_time/ExecuteTime.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ Main: ExecuteTime.js
77
Compatibility: 4.x, 5.x
88
Parameters:
99

10+
- name: ExecuteTime.clear_timings_on_kernel_restart
11+
description: |
12+
Clear all cells' execution timing data on any kernel restart event
13+
input_type: checkbox
14+
default: false
15+
1016
- name: ExecuteTime.display_absolute_timings
1117
description: |
1218
Display absolute timings for the start time of execution.

src/jupyter_contrib_nbextensions/nbextensions/execute_time/readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ ConfigManager().update('notebook', {'ExecuteTime': {
6060

6161
The available options are:
6262

63+
* `ExecuteTime.clear_timings_on_kernel_restart`: Clear all cells' execution
64+
timing data on any kernel restart event
65+
6366
* `ExecuteTime.display_absolute_timings`: Display absolute timings for the
6467
start/end time of execution. Setting this `false` will result in the display
6568
of a relative timestamp like 'a few seconds ago' (see the moment.js function

0 commit comments

Comments
 (0)