2 % (c) The GRASP/AQUA Project, Glasgow University, 1995
4 \section[LibCPUTime]{Haskell 1.3 CPU Time Library}
7 module LibCPUTime where
11 getCPUTime :: IO Integer
13 newIntArray (0,3) `thenPrimIO` \ marr ->
14 unsafeFreezeByteArray marr `thenPrimIO` \ barr@(_ByteArray _ frozen#) ->
15 _ccall_ getCPUTime barr `thenPrimIO` \ ptr ->
16 if (ptr::_Addr) /= ``NULL'' then
17 return (fromInt (I# (indexIntArray# frozen# 0#)) * 1000000000 +
18 fromInt (I# (indexIntArray# frozen# 1#)) +
19 fromInt (I# (indexIntArray# frozen# 2#)) * 1000000000 +
20 fromInt (I# (indexIntArray# frozen# 3#)))
22 failWith (UnsupportedOperation "can't get CPU time")
26 Computation $getCPUTime$ returns the number of nanoseconds CPU time
27 used by the current program. The precision of this result is
28 implementation-dependent.