summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/Clock.hsc
blob: 6339dc0a52b1e49b56f723de78908a1dbd8adc98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude #-}

module GHC.Clock
    ( getMonotonicTime
    , getMonotonicTimeNSec
    ) where

import GHC.Base
import GHC.Real
import Data.Word

-- | Return monotonic time in seconds, since some unspecified starting point
--
-- @since 4.11.0.0
getMonotonicTime :: IO Double
getMonotonicTime = do w <- getMonotonicTimeNSec
                      return (fromIntegral w / 1000000000)

-- | Return monotonic time in nanoseconds, since some unspecified starting point
--
-- @since 4.11.0.0
foreign import ccall unsafe "getMonotonicNSec"
    getMonotonicTimeNSec :: IO Word64