[MLton-commit] r7062

Matthew Fluet fluet at mlton.org
Wed Apr 8 05:32:42 PDT 2009


Use Timer.* functions.

Fetch GC time first, so that it will (more likely) be included in self.
----------------------------------------------------------------------

U   mlton/trunk/lib/mlton-stubs/mlton.sml

----------------------------------------------------------------------

Modified: mlton/trunk/lib/mlton-stubs/mlton.sml
===================================================================
--- mlton/trunk/lib/mlton-stubs/mlton.sml	2009-04-08 12:32:06 UTC (rev 7061)
+++ mlton/trunk/lib/mlton-stubs/mlton.sml	2009-04-08 12:32:41 UTC (rev 7062)
@@ -322,18 +322,22 @@
 
            fun measureGC _ = ()
 
-           (* Fake it with Posix.ProcEnv.times *)
+           (* Fake it with Posix.ProcEnv.times
+            * and Timer.totalCPUTimer and Timer.checkCPUTimes.
+            *)
            fun rusage () =
               let
                  val zero = {utime = Time.zeroTime, stime = Time.zeroTime}
               in
                  let
+                    val {gc = {usr = gcutime, sys = gcstime}, ...} =
+                       Timer.checkCPUTimes (Timer.totalCPUTimer ())
                     val {utime, stime, cutime, cstime, ...} =
                        Posix.ProcEnv.times ()
                  in
                     {self = {utime = utime, stime = stime},
                      children = {utime = cutime, stime = cstime},
-                     gc = zero}
+                     gc = {utime = gcutime, stime = gcstime}}
                  end handle Time => {children = zero, gc = zero, self = zero}
                  (* The handle Time is there because of a bug in SML/NJ that
                   * causes a Time exception to be raised on machines with a




More information about the MLton-commit mailing list