packages feed

MicroHs-0.17.4.0 / lib / System / CPUTime.hs

module System.CPUTime(getCPUTime, cpuTimePrecision) whereimport qualified Prelude()import MiniPreludeimport Data.Integerimport Foreign.C.Typesimport Foreign.Marshal.Utilsimport Foreign.Ptrimport Foreign.Storableforeign import ccall getcpu :: Ptr CULong -> Ptr CULong -> IO ()getCPUTime :: IO IntegergetCPUTime = do  psec <- new 0  pnsec <- new 0  getcpu psec pnsec  sec <- peek psec  nsec <- peek pnsec  return $ toInteger sec * 1000_000_000_000 + toInteger nsec * 1000-- Arbitrarily set it to  1us.-- Using the system call clock_getres() will not give an accurate-- result anyway.cpuTimePrecision :: IntegercpuTimePrecision = 1_000_000