cpcloud / ipython-autotime

Time everything in IPython
Apache License 2.0
118 stars 12 forks source link

Feature request: print only when time is above a threshold #18

Closed valerio-marra closed 3 years ago

valerio-marra commented 3 years ago

I would find it useful to display the time a cell took only when this time is above a threshold. This would make the notebook cleaner as one may be interested only in computationally intensive cells.

ddelange commented 3 years ago

Hi @valerio-marra,

Allowing configuration of IPython extensions upon %load_ext is not trivial and a bit controversial (ref https://github.com/ipython/ipython/issues/6888).

I would argue it's a feature of this extension to always output a delta, whether the cell succeeds, crashes, takes little or lots of time.

If you're feeling like forking for personal purposes, you could simply use a global variable or a class attribute (in seconds):

def stop(self):
    delta = monotonic() - self.start_time
-    print(u'time: {}'.format(format_delta(delta)))
+    if delta >= DELTA_THRESHOLD:
+        print(u'time: {}'.format(format_delta(delta)))
valerio-marra commented 3 years ago

thanks!