diff --git a/src/jupyter_contrib_nbextensions/nbextensions/execute_time/ExecuteTime.js b/src/jupyter_contrib_nbextensions/nbextensions/execute_time/ExecuteTime.js index 5bc0ca4f3..5ee9fae50 100755 --- a/src/jupyter_contrib_nbextensions/nbextensions/execute_time/ExecuteTime.js +++ b/src/jupyter_contrib_nbextensions/nbextensions/execute_time/ExecuteTime.js @@ -49,6 +49,7 @@ define([ executed: 'executed in ${duration}, finished ${end_time}', queued: 'execution queued ${start_time}', }, + hide_shorter_than_threshold_in_ms: 0, }; function patch_CodeCell_get_callbacks () { @@ -263,12 +264,16 @@ define([ end_time = cell.metadata.ExecuteTime.end_time; var msg = options.template[end_time ? 'executed' : 'queued']; msg = msg.replace('${start_time}', format_moment(start_time)); + var show_timing = true; if (end_time) { end_time = moment(end_time); msg = msg.replace('${end_time}', format_moment(end_time)); var exec_time = -start_time.diff(end_time); msg = msg.replace('${duration}', humanized_duration(exec_time)); + show_timing = exec_time >= options.hide_shorter_than_threshold_in_ms; } + toggle_timing_display([cell], show_timing); + timing_area.text(msg); return timing_area; } diff --git a/src/jupyter_contrib_nbextensions/nbextensions/execute_time/ExecuteTime.yaml b/src/jupyter_contrib_nbextensions/nbextensions/execute_time/ExecuteTime.yaml index 583a1e478..846400cae 100644 --- a/src/jupyter_contrib_nbextensions/nbextensions/execute_time/ExecuteTime.yaml +++ b/src/jupyter_contrib_nbextensions/nbextensions/execute_time/ExecuteTime.yaml @@ -86,3 +86,12 @@ Parameters: replacement tokens. default: 'execution queued ${start_time}' input_type: text + +- name: ExecuteTime.hide_shorter_than_threshold_in_ms + description: | + Hide execution timings that are shorter than this threshold (in ms). Set to + zero to show all timings. + default: 0 + input_type: number + step: 1 + min: 1 diff --git a/src/jupyter_contrib_nbextensions/nbextensions/execute_time/readme.md b/src/jupyter_contrib_nbextensions/nbextensions/execute_time/readme.md index 1437f0263..a424eaaa0 100644 --- a/src/jupyter_contrib_nbextensions/nbextensions/execute_time/readme.md +++ b/src/jupyter_contrib_nbextensions/nbextensions/execute_time/readme.md @@ -113,6 +113,10 @@ The available options are: cells. The template uses an ES2015-like syntax, but replaces only the exact strings `${start_time}`, plus (if defined) `${end_time}` and `${duration}`. Defaults to `'execution queued ${start_time}'`. + +* `ExecuteTime.hide_shorter_than_threshold_in_ms`: Threshold to hide execution + timings that are short. Set this to zero to show all timings. + Defaults to `0`.