System.Clock.Seconds

clock-0.8.4: High-resolution clock functions: monotonic, realtime, cputime.

Safe Haskell | None
Language | Haskell2010

System.Clock.Seconds

Synopsis

- data Clock
  - = Monotonic
  - | Realtime
  - | ProcessCPUTime
  - | ThreadCPUTime
- newtype Seconds = Seconds {
  - toTimeSpec :: TimeSpec
  }
- getTime :: Clock -> IO Seconds
- getRes :: Clock -> IO Seconds
- fromNanoSecs :: Integer -> Seconds
- toNanoSecs :: Seconds -> Integer
- diffTimeSpec :: Seconds -> Seconds -> Seconds

# Documentation

data Clock #

Clock types. A clock may be system-wide (that is, visible to all processes) or per-process (measuring time that is meaningful only within a process). All implementations shall support `Realtime`.

Constructors

Monotonic | The identifier for the system-wide monotonic clock, which is defined as a clock measuring real time, whose value cannot be set via `clock_settime` and which cannot have negative clock jumps. The maximum possible clock jump shall be implementation defined. For this clock, the value returned by `getTime` represents the amount of time (in seconds and nanoseconds) since an unspecified point in the past (for example, system start-up time, or the Epoch). This point does not change after system start-up time. Note that the absolute value of the monotonic clock is meaningless (because its origin is arbitrary), and thus there is no need to set it. Furthermore, realtime applications can rely on the fact that the value of this clock is never set. (Identical to `Boottime` since Linux 4.17, see https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d6ed449afdb38f89a7b38ec50e367559e1b8f71f) `CLOCK_MONOTONIC` (macOS - `SYSTEM_CLOCK`)
Realtime | The identifier of the system-wide clock measuring real time. For this clock, the value returned by `getTime` represents the amount of time (in seconds and nanoseconds) since the Epoch. `CLOCK_REALTIME` (macOS - `CALENDAR_CLOCK`, Windows - `GetSystemTimeAsFileTime`)
ProcessCPUTime | The identifier of the CPU-time clock associated with the calling process. For this clock, the value returned by `getTime` represents the amount of execution time of the current process.
ThreadCPUTime | The identifier of the CPU-time clock associated with the calling OS thread. For this clock, the value returned by `getTime` represents the amount of execution time of the current OS thread.

#### Instances

Instances details

Enum Clock # |
Instance details Defined in System.Clock Methods succ :: Clock -> Clock # pred :: Clock -> Clock # toEnum :: Int -> Clock # fromEnum :: Clock -> Int # enumFrom :: Clock -> [Clock] # enumFromThen :: Clock -> Clock -> [Clock] # enumFromTo :: Clock -> Clock -> [Clock] # enumFromThenTo :: Clock -> Clock -> Clock -> [Clock] #
Generic Clock # |
Instance details Defined in System.Clock Associated Types
type Rep Clock |
Instance details Defined in System.Clock type Rep Clock = D1 ('MetaData "Clock" "System.Clock" "clock-0.8.4-BoSBw0VDB82KWo50HGG2ac" 'False) ((C1 ('MetaCons "Monotonic" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Realtime" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "ProcessCPUTime" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ThreadCPUTime" 'PrefixI 'False) (U1 :: Type -> Type)))
Methods from :: Clock -> Rep Clock x # to :: Rep Clock x -> Clock #
Read Clock # |
Instance details Defined in System.Clock Methods readsPrec :: Int -> ReadS Clock # readList :: ReadS [Clock] # readPrec :: ReadPrec Clock # readListPrec :: ReadPrec [Clock] #
Show Clock # |
Instance details Defined in System.Clock Methods showsPrec :: Int -> Clock -> ShowS # show :: Clock -> String # showList :: [Clock] -> ShowS #
Eq Clock # |
Instance details Defined in System.Clock Methods (==) :: Clock -> Clock -> Bool # (/=) :: Clock -> Clock -> Bool #
type Rep Clock # |
Instance details Defined in System.Clock type Rep Clock = D1 ('MetaData "Clock" "System.Clock" "clock-0.8.4-BoSBw0VDB82KWo50HGG2ac" 'False) ((C1 ('MetaCons "Monotonic" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Realtime" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "ProcessCPUTime" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ThreadCPUTime" 'PrefixI 'False) (U1 :: Type -> Type)))

newtype Seconds #

Constructors

Seconds |
Fields toTimeSpec :: TimeSpec

#### Instances

Instances details

Bounded Seconds # |
Instance details Defined in System.Clock.Seconds Methods minBound :: Seconds # maxBound :: Seconds #
Enum Seconds # |
Instance details Defined in System.Clock.Seconds Methods succ :: Seconds -> Seconds # pred :: Seconds -> Seconds # toEnum :: Int -> Seconds # fromEnum :: Seconds -> Int # enumFrom :: Seconds -> [Seconds] # enumFromThen :: Seconds -> Seconds -> [Seconds] # enumFromTo :: Seconds -> Seconds -> [Seconds] # enumFromThenTo :: Seconds -> Seconds -> Seconds -> [Seconds] #
Storable Seconds # |
Instance details Defined in System.Clock.Seconds Methods sizeOf :: Seconds -> Int # alignment :: Seconds -> Int # peekElemOff :: Ptr Seconds -> Int -> IO Seconds # pokeElemOff :: Ptr Seconds -> Int -> Seconds -> IO () # peekByteOff :: Ptr b -> Int -> IO Seconds # pokeByteOff :: Ptr b -> Int -> Seconds -> IO () # peek :: Ptr Seconds -> IO Seconds # poke :: Ptr Seconds -> Seconds -> IO () #
Generic Seconds # |
Instance details Defined in System.Clock.Seconds Associated Types
type Rep Seconds |
Instance details Defined in System.Clock.Seconds type Rep Seconds = D1 ('MetaData "Seconds" "System.Clock.Seconds" "clock-0.8.4-BoSBw0VDB82KWo50HGG2ac" 'True) (C1 ('MetaCons "Seconds" 'PrefixI 'True) (S1 ('MetaSel ('Just "toTimeSpec") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TimeSpec)))
Methods from :: Seconds -> Rep Seconds x # to :: Rep Seconds x -> Seconds #
Num Seconds # |
Instance details Defined in System.Clock.Seconds Methods (+) :: Seconds -> Seconds -> Seconds # (-) :: Seconds -> Seconds -> Seconds # (*) :: Seconds -> Seconds -> Seconds # negate :: Seconds -> Seconds # abs :: Seconds -> Seconds # signum :: Seconds -> Seconds # fromInteger :: Integer -> Seconds #
Read Seconds # |
Instance details Defined in System.Clock.Seconds Methods readsPrec :: Int -> ReadS Seconds # readList :: ReadS [Seconds] # readPrec :: ReadPrec Seconds # readListPrec :: ReadPrec [Seconds] #
Fractional Seconds # |
Instance details Defined in System.Clock.Seconds Methods (/) :: Seconds -> Seconds -> Seconds # recip :: Seconds -> Seconds # fromRational :: Rational -> Seconds #
Real Seconds # |
Instance details Defined in System.Clock.Seconds Methods toRational :: Seconds -> Rational #
RealFrac Seconds # |
Instance details Defined in System.Clock.Seconds Methods properFraction :: Integral b => Seconds -> (b, Seconds) # truncate :: Integral b => Seconds -> b # round :: Integral b => Seconds -> b # ceiling :: Integral b => Seconds -> b # floor :: Integral b => Seconds -> b #
Show Seconds # |
Instance details Defined in System.Clock.Seconds Methods showsPrec :: Int -> Seconds -> ShowS # show :: Seconds -> String # showList :: [Seconds] -> ShowS #
Eq Seconds # |
Instance details Defined in System.Clock.Seconds Methods (==) :: Seconds -> Seconds -> Bool # (/=) :: Seconds -> Seconds -> Bool #
Ord Seconds # |
Instance details Defined in System.Clock.Seconds Methods compare :: Seconds -> Seconds -> Ordering # (<) :: Seconds -> Seconds -> Bool # (<=) :: Seconds -> Seconds -> Bool # (>) :: Seconds -> Seconds -> Bool # (>=) :: Seconds -> Seconds -> Bool # max :: Seconds -> Seconds -> Seconds # min :: Seconds -> Seconds -> Seconds #
type Rep Seconds # |
Instance details Defined in System.Clock.Seconds type Rep Seconds = D1 ('MetaData "Seconds" "System.Clock.Seconds" "clock-0.8.4-BoSBw0VDB82KWo50HGG2ac" 'True) (C1 ('MetaCons "Seconds" 'PrefixI 'True) (S1 ('MetaSel ('Just "toTimeSpec") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TimeSpec)))

getTime :: Clock -> IO Seconds #

The `getTime` function shall return the current value for the specified clock.

getRes :: Clock -> IO Seconds #

The `getRes` function shall return the resolution of any clock. Clock resolutions are implementation-defined and cannot be set by a process.

fromNanoSecs :: Integer -> Seconds #

Seconds from nano seconds.

toNanoSecs :: Seconds -> Integer #

Seconds to nano seconds.

diffTimeSpec :: Seconds -> Seconds -> Seconds #

Compute the absolute difference.