File tree Expand file tree Collapse file tree 3 files changed +18
-0
lines changed
src/jupyter_contrib_nbextensions/nbextensions/execute_time Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ define([
49
49
executed : 'executed in ${duration}, finished ${end_time}' ,
50
50
queued : 'execution queued ${start_time}' ,
51
51
} ,
52
+ hide_shorter_than_threshold_in_ms : 0 ,
52
53
} ;
53
54
54
55
function patch_CodeCell_get_callbacks ( ) {
@@ -263,12 +264,16 @@ define([
263
264
end_time = cell . metadata . ExecuteTime . end_time ;
264
265
var msg = options . template [ end_time ? 'executed' : 'queued' ] ;
265
266
msg = msg . replace ( '${start_time}' , format_moment ( start_time ) ) ;
267
+ var show_timing = true ;
266
268
if ( end_time ) {
267
269
end_time = moment ( end_time ) ;
268
270
msg = msg . replace ( '${end_time}' , format_moment ( end_time ) ) ;
269
271
var exec_time = - start_time . diff ( end_time ) ;
270
272
msg = msg . replace ( '${duration}' , humanized_duration ( exec_time ) ) ;
273
+ show_timing = exec_time >= options . hide_shorter_than_threshold_in_ms ;
271
274
}
275
+ toggle_timing_display ( [ cell ] , show_timing ) ;
276
+
272
277
timing_area . text ( msg ) ;
273
278
return timing_area ;
274
279
}
Original file line number Diff line number Diff line change @@ -86,3 +86,12 @@ Parameters:
86
86
replacement tokens.
87
87
default : ' execution queued ${start_time}'
88
88
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
Original file line number Diff line number Diff line change @@ -113,6 +113,10 @@ The available options are:
113
113
cells. The template uses an ES2015-like syntax, but replaces only the exact
114
114
strings ` ${start_time} ` , plus (if defined) ` ${end_time} ` and ` ${duration} ` .
115
115
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 ` .
116
120
117
121
118
122
You can’t perform that action at this time.
0 commit comments