Timing
Millisecond timing support when the underlying operating system supports it.
timing
Time command, similar to
timebut uses internal functions
Usage
timing command [ --help ] [ --name ] [ --slow slowMilliseconds ] [ --fast fastMilliseconds ]
Time command, similar to time but uses internal functions
Outputs time as timingReport
Location:
bin/build/tools/timing.sh
Arguments
command- Executable. Required. Command to run.--help- Flag. Optional. Display this help.--name- String. Optional. Display this help.--slow slowMilliseconds- UnsignedInteger. Optional. Display output if the underlying commend takes is slower (longer) than this threshold.--fast fastMilliseconds- UnsignedInteger. Optional. Display output if the underlying commend runs is faster (shorter) than this threshold.
Return codes
0- Success1- Environment error2- Argument error
timingElapsed
Show elapsed time from a start time
Usage
timingElapsed timingOffset [ --help ]
Show elapsed time from a start time
Location:
bin/build/tools/timing.sh
Arguments
timingOffset- UnsignedInteger. Required. Offset in milliseconds from January 1, 1970.--help- Flag. Optional. Display this help.
Writes to standard output
UnsignedInteger
Examples
init=$(timingStart)
...
timingElapsed "$init"
Sample Output
4232
Return codes
0- Success1- Environment error2- Argument error
Requires
- returnEnvironment - Return `environment` error code. Outputs `message ...` to `stderr`. (source)
- validate - Validate a value by type (source)
date
timingStart
Start a timer
Usage
timingStart [ --help ]
Outputs the offset in milliseconds from midnight UTC January 1, 1970.
Only fails if date is not installed
Location:
bin/build/tools/timing.sh
Arguments
--help- Flag. Optional. Display this help.
Writes to standard output
UnsignedInteger
Sample Output
1777501474602
Return codes
0- Success1- Environment error2- Argument error
Requires
- __timestamp,
- returnEnvironment - Return `environment` error code. Outputs `message ...` to `stderr`. (source)
date
timingFormat
Format a timing output (milliseconds) as seconds using a decimal
Usage
timingFormat [ --help ] [ delta ]
Format a timing output (milliseconds) as seconds using a decimal
Location:
bin/build/tools/timing.sh
Arguments
--help- Flag. Optional. Display this help.delta- Integer. Milliseconds
Return codes
0- Success1- Environment error2- Argument error
timingDuration
Output timing like "1 day, 2 hours, 3 minutes, 4
Usage
timingDuration [ duration ] [ --help ] [ --handler handler ] [ --stop stopUnit ]
Output timing like "1 day, 2 hours, 3 minutes, 4 seconds, 5 ms"
Location:
bin/build/tools/timing.sh
Arguments
duration- UnsignedInteger. Optional. Timing to output--help- Flag. Optional. Display this help.--handler handler- Function. Optional. Use this error handler instead of the default error handler.--stop stopUnit- String. Optional. Stop displaying fractional output after this unit is displayed.
Return codes
0- Success1- Environment error2- Argument error
timingReport
Output the time elapsed
Usage
timingReport [ --slow slowMilliseconds ] [ --fast fastMilliseconds ] [ --style style ] [ --color style ] [ --end endTimestamp ] start [ message ] [ --help ] [ --handler handler ]
Outputs the timing optionally prefixed by a message.
Outputs a nice colorful message showing the number of seconds elapsed as well as your custom message.
Condition additions --slow and --fast allow display conditional on the time output.
Location:
bin/build/tools/timing.sh
Arguments
--slow slowMilliseconds- UnsignedInteger. Optional. Display output if the displayed time is slower (longer) than this threshold.--fast fastMilliseconds- UnsignedInteger. Optional. Display output if the displayed time is faster (shorter) than this threshold.--style style- String. Optional. Display the message using this style. Default style issuccess--color style- String. Optional. Display the message using this style. Default style issuccess. Deprecated 2026-04.--end endTimestamp- UnsignedInteger. Optional. Use this as the end time to display. Otherwise uses the current time. Unit is milliseconds.start- UnsignedInteger|EmptyString. Required. Unix timestamp in milliseconds. SeetimingStart. Unit ismilliseconds. Invalid values do NOT produce an error.message- Any additional arguments are output before the elapsed value computed--help- Flag. Optional. Display this help.--handler handler- Function. Optional. Use this error handler instead of the default error handler.
Examples
init=$(timingStart)
...
timingReport "$init" "Deploy completed in"
timingReport "$start" --slow 5000 "Reporting should be completed in less than 5 seconds."
timingReport "$start" --fast 1000 --style error "Deployment completed too quickly; please check systems."
Return codes
0- Exits with exit code zero
See Also
- timingStart - Start a timer (source)