BuildkiteTestCollector.Instant (buildkite_test_collector v0.2.0)

Represents a single instant with microsecond accuracy.

Wraps monotonic time to ensure that there are no unit mistakes.

why-not-just-use-datetime-instead

Why not just use DateTime instead?

Sadly, the wall clock time can move backwards and forwards between samples (for example if NTP is updating the clock, or during a daylight savings transition). The system monotonic clock always moves forwards, regardless of the current wall clock time. This means it's no good for measuring the absolute time, but is perfect for measuring relative time.

See erlang:monotonic_time/0 for more information.

Link to this section Summary

Functions

Add a duration to an instant and return a new instant.

Return an instant representing "now" as understood by the system's monotonic clock.

Link to this section Types

@type t() :: %BuildkiteTestCollector.Instant{usec: integer()}

Link to this section Functions

Link to this function

add(instant, duration)

@spec add(t(), BuildkiteTestCollector.Duration.t()) :: t()

Add a duration to an instant and return a new instant.

@spec now() :: t()

Return an instant representing "now" as understood by the system's monotonic clock.