BuildkiteTestCollector.Duration (buildkite_test_collector v0.1.1)

The analyics API specifies start and end times in fractional seconds since the beginning of the test run.

It's convenient for us to store these as a duration by specifying their start time and end time and then calculating the diference when serialising into JSON.

Internally these times are stored as microseconds from the system's monotonic clock. See System.monotonic_time/1 for more information.

Link to this section Summary

Functions

The duration of the timing, in (fractional) seconds.

The current time based on a zero-microsecond epoch.

Return a new now time based on the provided epoch.

Link to this section Types

Link to this type

microseconds()

@type microseconds() :: integer()
@type seconds() :: float()
@type t() :: %BuildkiteTestCollector.Duration{
  epoch: microseconds(),
  offset: microseconds()
}

Link to this section Functions

Link to this function

as_seconds(duration)

@spec as_seconds(t()) :: seconds()

The duration of the timing, in (fractional) seconds.

@spec now() :: t()

The current time based on a zero-microsecond epoch.

This esspentially returns a duration since the beginning of time, and is not that useful until you use it to as the epoch for other durations.

@spec since(t()) :: t()

Return a new now time based on the provided epoch.