[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / lib / haskell-1.3 / LibCPUTime.lhs
diff --git a/ghc/lib/haskell-1.3/LibCPUTime.lhs b/ghc/lib/haskell-1.3/LibCPUTime.lhs
new file mode 100644 (file)
index 0000000..c3db93e
--- /dev/null
@@ -0,0 +1,31 @@
+%
+% (c) The GRASP/AQUA Project, Glasgow University, 1995
+%
+\section[LibCPUTime]{Haskell 1.3 CPU Time Library}
+
+\begin{code}
+module LibCPUTime where
+
+import PreludeGlaST
+
+getCPUTime :: IO Integer
+getCPUTime =
+    _ccall_ getCPUTime                             `thenPrimIO` \ ptr@(A# ptr#) ->
+    if ptr /= ``NULL'' then
+        return (fromInt (I# (indexIntOffAddr# ptr# 0#)) * 1000000000 + 
+                fromInt (I# (indexIntOffAddr# ptr# 1#)) + 
+               fromInt (I# (indexIntOffAddr# ptr# 2#)) * 1000000000 + 
+                fromInt (I# (indexIntOffAddr# ptr# 3#)))
+    else
+       failWith (UnsupportedOperation "can't get CPU time")
+
+\end{code}
+
+Computation $getCPUTime$ returns the number of nanoseconds CPU time
+used by the current program.  The precision of this result is
+implementation-dependent.
+
+
+
+
+