Elapsed time and system information

Elapsed time and system information#

When running complex Jupyter notebooks, or notebooks that require a certain execution time, it is useful to store, at the end of their execution, a summary of the time required for their completion. The function elapsed_time_since() has been defined not only to provide this information, but also to report other interesting parameters, such as the operating system, and the versions of Python and teareduce used.

Its usage is very simple: just define a datetime object at the top of the notebook, and then call the function elapsed_time_since(), passing this initial time as an argument.

from datetime import datetime
import teareduce as tea
import time
time_ini = datetime.now()
time.sleep(2)
tea.elapsed_time_since(time_ini)
system...........: Linux
release..........: 6.11.0-1018-azure
machine..........: x86_64
node.............: runnervmymu0l
Python executable: /opt/hostedtoolcache/Python/3.12.12/x64/bin/python
teareduce version: 0.6.9
Initial time.....: 2026-01-27 04:38:03.596840
Final time.......: 2026-01-27 04:38:05.606159
Elapsed time.....: 0:00:02.009319

There is also a related function, named elapsed_time(), that perform the same action by making use of two input parameters: the initial and the final time.

time_end = datetime.now()

tea.elapsed_time(time_ini, time_end)
system...........: Linux
release..........: 6.11.0-1018-azure
machine..........: x86_64
node.............: runnervmymu0l
Python executable: /opt/hostedtoolcache/Python/3.12.12/x64/bin/python
teareduce version: 0.6.9
Initial time.....: 2026-01-27 04:38:03.596840
Final time.......: 2026-01-27 04:38:05.610781
Elapsed time.....: 0:00:02.013941