toc#
- toc(start=None, label=None, baselabel=None, sigfigs=None, reset=False, unit='s', output=False, doprint=None, elapsed=None)[source]#
With
sc.tic()
, a little pair of functions to calculate a time difference. See alsosc.timer()
.By default, output is displayed in seconds. You can change this with the
unit
argument, which can be a string or a float:‘hr’ or 3600
‘min’ or 60
‘s’ or 1 (default)
‘ms’ or 1e-3
‘us’ or 1e-6
‘ns’ or 1e-9
‘auto’ to choose an appropriate unit
- Parameters:
start (float) – the starting time, as returned by e.g.
sc.tic()
label (str) – optional label to add
baselabel (str) – optional base label; default is “Elapsed time: “
sigfigs (int) – number of significant figures for time estimate
reset (bool) – reset the time; like calling
sc.toctic()
orsc.tic()
againunit (str/float) – the unit of time to display; see options above
output (bool) – whether to return the output (otherwise print); if output=’message’, then return the message string; if output=’both’, then return both
doprint (bool) – whether to print (true by default)
elapsed (float) – use a pre-calculated elapsed time instead of recalculating (not recommneded)
Examples:
sc.tic() slow_func() sc.toc() T = sc.tic() slow_func2() sc.toc(T, label='slow_func2')
New in version 1.3.0: new arguments New in version 3.0.0: “unit” argument