File tree Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -11,10 +11,10 @@ $ pip install ipython-autotime
1111
1212``` python
1313In [1 ]: % load_ext autotime
14- time: 295 µs
14+ time: 264 µs (started: 2020 - 12 - 15 11 : 44 : 36 + 0 100 )
1515
1616In [2 ]: x = 1
17- time: 519 µs
17+ time: 416 µs (started: 2020 - 12 - 15 11 : 44 : 45 + 0 100 )
1818
1919In [3 ]: x / 0
2020-------------------------------------------------------------------------- -
@@ -23,7 +23,7 @@ ZeroDivisionError Traceback (most recent call last)
2323---- > 1 x/ 0
2424
2525ZeroDivisionError : division by zero
26- time: 79 .7 ms
26+ time: 88 .7 ms (started: 2020 - 12 - 15 11 : 44 : 53 + 0 100 )
2727```
2828
2929## Want to turn it off?
Original file line number Diff line number Diff line change 22
33from ._version import version as __version__
44
5+ from time import strftime , localtime
6+
57try :
68 from time import monotonic
79except ImportError :
@@ -17,14 +19,20 @@ class LineWatcher(object):
1719 -----
1820 * Register the `start` and `stop` methods with the IPython events API.
1921 """
20- __slots__ = ['start_time' ]
22+ __slots__ = ['start_time' , 'timestamp' ]
2123
2224 def start (self ):
25+ self .timestamp = localtime ()
2326 self .start_time = monotonic ()
2427
2528 def stop (self ):
2629 delta = monotonic () - self .start_time
27- print (u'time: {}' .format (format_delta (delta )))
30+ print (
31+ u'time: {} (started: {})' .format (
32+ format_delta (delta ),
33+ strftime ('%Y-%m-%d %H:%M:%S%z' , self .timestamp ),
34+ )
35+ )
2836
2937
3038timer = LineWatcher ()
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ def test_full_cycle():
1010 with tt .AssertPrints ('time: ' ):
1111 ip .run_cell ('%load_ext autotime' )
1212
13- with tt .AssertPrints ('time : ' ):
13+ with tt .AssertPrints (' (started : ' ):
1414 ip .run_cell ('x = 1' )
1515
1616 with tt .AssertNotPrints ('time: ' ):
You can’t perform that action at this time.
0 commit comments