sciris.sc_datetime.toc

toc(start=None, label=None, baselabel=None, sigfigs=None, reset=False, output=False, doprint=None, elapsed=None)[source]

With sc.tic(), a little pair of functions to calculate a time difference. See also sc.timer().

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() or sc.tic() again

  • 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.