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...........: Darwin
release..........: 25.2.0
machine..........: arm64
node.............: iblax.fis.ucm.es
Python executable: /Users/cardiel/venv_tea/bin/python3.13
teareduce version: 0.7.1
Initial time.....: 2026-02-06 09:29:52.516518
Final time.......: 2026-02-06 09:29:54.529829
Elapsed time.....: 0:00:02.013311
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...........: Darwin
release..........: 25.2.0
machine..........: arm64
node.............: iblax.fis.ucm.es
Python executable: /Users/cardiel/venv_tea/bin/python3.13
teareduce version: 0.7.1
Initial time.....: 2026-02-06 09:29:52.516518
Final time.......: 2026-02-06 09:29:54.538541
Elapsed time.....: 0:00:02.022023