Skip to content

Timing

🛠️ Tools · ⬅ Top


Millisecond timing support when the underlying operating system supports it.

timing

Time command, similar to time but uses internal functions

Usage

timing command [ --help ]

Time command, similar to time but uses internal functions Outputs time as timingReport

Arguments

  • command - Required. Executable. Command to run.
  • --help - Optional. Flag. Display this help.

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

timingStart

Start a timer

Usage

timingStart [ --help ]

Outputs the offset in milliseconds from January 1, 1970.

Should never fail, unless date is not installed

Arguments

  • --help - Optional. Flag. Display this help.

Examples

init=$(timingStart)
...
timingReport "$init" "Completed in"

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

Requires

__timestamp, returnEnvironment 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

Arguments

  • --help - Optional. Flag. Display this help.
  • delta - Integer. Milliseconds

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

timingReport

Output the time elapsed

Usage

timingReport [ --color color ] [ --help ] [ --handler handler ] [ start ] [ message ]

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. Return Code: 0 - Exits with exit code zero

Arguments

  • --color color - Make text this color (default is green)
  • --help - Optional. Flag. Display this help.
  • --handler handler - Optional. Function. Use this error handler instead of the default error handler.
  • start - Unix timestamp milliseconds. See timingStart.
  • message - Any additional arguments are output before the elapsed value computed

Examples

init=$(timingStart)
...
timingReport "$init" "Deploy completed in"

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error