module GHC.Eventlog.Live.Data.Span (
IsSpan,
duration,
) where
import GHC.RTS.Events (Timestamp)
import GHC.Records (HasField)
type IsSpan s = (HasField "startTimeUnixNano" s Timestamp, HasField "endTimeUnixNano" s Timestamp)
duration :: (IsSpan s) => s -> Timestamp
duration :: forall s. IsSpan s => s -> Timestamp
duration s
s = if s
s.startTimeUnixNano Timestamp -> Timestamp -> Bool
forall a. Ord a => a -> a -> Bool
< s
s.endTimeUnixNano then s
s.endTimeUnixNano Timestamp -> Timestamp -> Timestamp
forall a. Num a => a -> a -> a
- s
s.startTimeUnixNano else Timestamp
0
{-# INLINEABLE duration #-}