๐ time
time::convertMicrosecondsToHuman
Convert microseconds to human readable format.
- $1: microseconds as int: the microseconds to convert
- $2: format as string:
(optional) Can be set using the variable
_OPTION_FORMAT
. the format to use (defaults to โ%HH:%MM:%SSโ) Usable formats:- %HH: hours
- %MM: minutes
- %SS: seconds
- %LL: milliseconds
- %h: hours without leading zero
- %m: minutes without leading zero
- %s: seconds without leading zero
- %l: milliseconds without leading zero
- %u: microseconds without leading zero
- %M: total minutes
- %S: total seconds
- %L: total milliseconds
- %U: total microseconds
Returns:
- ${RETURNED_VALUE}: the human readable format
time::convertMicrosecondsToHuman 123456789
echo "${RETURNED_VALUE}"
time::getDate
Get the current date in the given format.
- $1: format as string: (optional) the format of the date to return (defaults to %(%F_%Hh%Mm%Ss)T).
Returns:
- ${RETURNED_VALUE}: the current date in the given format.
time::getDate
local date="${RETURNED_VALUE}"
This function avoid to call $(date) in a subshell (date is a an external executable).
time::getProgramElapsedMicroseconds
Get the elapsed time in ยตs since the program started.
Returns:
- ${RETURNED_VALUE}: the elapsed time in ยตs since the program started.
core::getElapsedProgramTime
echo "${RETURNED_VALUE}"
time::convertMicrosecondsToHuman "${RETURNED_VALUE}"
echo "Human time: ${RETURNED_VALUE}"
We split the computation in seconds and milliseconds to avoid overflow on 32-bit systems. The 10# forces the base 10 conversion to avoid issues with leading zeros. Fun fact: this function will fail in 2038 on 32-bit systems because the number of seconds will overflow.
time::getTimerMicroseconds
Get the time elapsed since the call of time::startTimer
.
- ${_OPTION_LOG_ELAPSED_TIME} as bool: (optional) Wether or not to log the elapsed time. (defaults to false)
- ${_OPTION_FORMAT} as string:
(optional) The format to use if we log the elapsed time.
See
time::convertMicrosecondsToHuman
for the format. (defaults to โ%S.%LLsโ).
Returns:
- ${RETURNED_VALUE}: the elapsed time in microseconds.
time::startTimer
_OPTION_LOG_ELAPSED_TIME=true time::getTimerMicroseconds
echo "Total microseconds: ${RETURNED_VALUE}"
time::startTimer
Start a timer. You can then call time::getTimerMicroseconds
to get the elapsed time.
time::startTimer
time::getTimerMicroseconds
โน๏ธ
Documentation generated for the version 0.29.197 (2025-03-29).