Skip to content

Commit db90d9c

Browse files
authored
Merge pull request ipython-contrib#1336 from Tautvis/master
Add short execution threshold for ExecutionTime plugin
2 parents 218a91f + 9334b85 commit db90d9c

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/jupyter_contrib_nbextensions/nbextensions/execute_time/ExecuteTime.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ define([
4949
executed: 'executed in ${duration}, finished ${end_time}',
5050
queued: 'execution queued ${start_time}',
5151
},
52+
hide_shorter_than_threshold_in_ms: 0,
5253
};
5354

5455
function patch_CodeCell_get_callbacks () {
@@ -263,12 +264,16 @@ define([
263264
end_time = cell.metadata.ExecuteTime.end_time;
264265
var msg = options.template[end_time ? 'executed' : 'queued'];
265266
msg = msg.replace('${start_time}', format_moment(start_time));
267+
var show_timing = true;
266268
if (end_time) {
267269
end_time = moment(end_time);
268270
msg = msg.replace('${end_time}', format_moment(end_time));
269271
var exec_time = -start_time.diff(end_time);
270272
msg = msg.replace('${duration}', humanized_duration(exec_time));
273+
show_timing = exec_time >= options.hide_shorter_than_threshold_in_ms;
271274
}
275+
toggle_timing_display([cell], show_timing);
276+
272277
timing_area.text(msg);
273278
return timing_area;
274279
}

src/jupyter_contrib_nbextensions/nbextensions/execute_time/ExecuteTime.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,12 @@ Parameters:
8686
replacement tokens.
8787
default: 'execution queued ${start_time}'
8888
input_type: text
89+
90+
- name: ExecuteTime.hide_shorter_than_threshold_in_ms
91+
description: |
92+
Hide execution timings that are shorter than this threshold (in ms). Set to
93+
zero to show all timings.
94+
default: 0
95+
input_type: number
96+
step: 1
97+
min: 1

src/jupyter_contrib_nbextensions/nbextensions/execute_time/readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ The available options are:
113113
cells. The template uses an ES2015-like syntax, but replaces only the exact
114114
strings `${start_time}`, plus (if defined) `${end_time}` and `${duration}`.
115115
Defaults to `'execution queued ${start_time}'`.
116+
117+
* `ExecuteTime.hide_shorter_than_threshold_in_ms`: Threshold to hide execution
118+
timings that are short. Set this to zero to show all timings.
119+
Defaults to `0`.
116120

117121

118122

0 commit comments

Comments
 (0)