clock_delta Function

public pure function clock_delta(t0, t1, max) result(dt)

Compute tick delta between two readings with wraparound handling.

Some system_clock implementations wrap at count_max. This helper treats t0 and t1 as readings from the same clock configuration.

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: t0

Start tick, end tick, and maximum tick before wrap.

integer(kind=int64), intent(in) :: t1

Start tick, end tick, and maximum tick before wrap.

integer(kind=int64), intent(in) :: max

Start tick, end tick, and maximum tick before wrap.

Return Value integer(kind=int64)


Source Code

   pure integer(int64) function clock_delta(t0, t1, max) result(dt)
      integer(int64), intent(in) :: t0, t1, max
      !! Start tick, end tick, and maximum tick before wrap.
      if (t1 >= t0) then
         dt = t1 - t0
      else
         dt = (max - t0 + 1_int64) + t1
      end if
   end function clock_delta