module Agda.Utils.Time
( ClockTime
, getClockTime
, measureTime
) where
import Control.Monad.Trans
import System.CPUTime
#if MIN_VERSION_directory(1,1,1)
import qualified Data.Time
#else
import qualified System.Time
#endif
type ClockTime =
#if MIN_VERSION_directory(1,1,1)
Data.Time.UTCTime
#else
System.Time.ClockTime
#endif
getClockTime :: IO ClockTime
getClockTime =
#if MIN_VERSION_directory(1,1,1)
Data.Time.getCurrentTime
#else
System.Time.getClockTime
#endif
type Picoseconds = Integer
measureTime :: MonadIO m => m a -> m (a, Picoseconds)
measureTime m = do
start <- liftIO $ getCPUTime
x <- m
stop <- liftIO $ getCPUTime
return (x, stop start)