[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / lib / haskell-1.3 / LibCPUTime.lhs
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1995
3 %
4 \section[LibCPUTime]{Haskell 1.3 CPU Time Library}
5
6 \begin{code}
7 module LibCPUTime where
8
9 import PreludeGlaST
10
11 getCPUTime :: IO Integer
12 getCPUTime =
13     _ccall_ getCPUTime                              `thenPrimIO` \ ptr@(A# ptr#) ->
14     if ptr /= ``NULL'' then
15         return (fromInt (I# (indexIntOffAddr# ptr# 0#)) * 1000000000 + 
16                 fromInt (I# (indexIntOffAddr# ptr# 1#)) + 
17                 fromInt (I# (indexIntOffAddr# ptr# 2#)) * 1000000000 + 
18                 fromInt (I# (indexIntOffAddr# ptr# 3#)))
19     else
20         failWith (UnsupportedOperation "can't get CPU time")
21
22 \end{code}
23
24 Computation $getCPUTime$ returns the number of nanoseconds CPU time
25 used by the current program.  The precision of this result is
26 implementation-dependent.
27
28
29
30
31