[MLton-commit] r4139

Matthew Fluet MLton@mlton.org
Thu, 3 Nov 2005 05:19:26 -0800


Moved implicit enabling of gcState.isRusageEnabled from MLton.Rusage to Timer
----------------------------------------------------------------------

U   mlton/trunk/basis-library/mlton/rusage.sml
U   mlton/trunk/basis-library/system/timer.sml

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

Modified: mlton/trunk/basis-library/mlton/rusage.sml
===================================================================
--- mlton/trunk/basis-library/mlton/rusage.sml	2005-11-03 07:46:08 UTC (rev 4138)
+++ mlton/trunk/basis-library/mlton/rusage.sml	2005-11-03 13:19:23 UTC (rev 4139)
@@ -28,20 +28,16 @@
              utime = toTime (utimeSec, utimeUsec)}
          end
 
-      val rusage =
-         let val () = MLtonGC.setRusage true
+      fun rusage () =
+         let
+            val () = Prim.ru ()
+            open Prim
          in
-            fn () =>
-            let
-               val () = Prim.ru ()
-               open Prim
-            in
-               {children = collect (children_utime_sec, children_utime_usec,
-                                    children_stime_sec, children_stime_usec),
-                gc = collect (gc_utime_sec, gc_utime_usec,
-                              gc_stime_sec, gc_stime_usec),
-                self = collect (self_utime_sec, self_utime_usec,
-                                self_stime_sec, self_stime_usec)}
-            end
+            {children = collect (children_utime_sec, children_utime_usec,
+                                 children_stime_sec, children_stime_usec),
+             gc = collect (gc_utime_sec, gc_utime_usec,
+                           gc_stime_sec, gc_stime_usec),
+             self = collect (self_utime_sec, self_utime_usec,
+                             self_stime_sec, self_stime_usec)}
          end
    end

Modified: mlton/trunk/basis-library/system/timer.sml
===================================================================
--- mlton/trunk/basis-library/system/timer.sml	2005-11-03 07:46:08 UTC (rev 4138)
+++ mlton/trunk/basis-library/system/timer.sml	2005-11-03 13:19:23 UTC (rev 4139)
@@ -21,14 +21,19 @@
       
       type cpu_timer = {gc: SysUsr.t, self: SysUsr.t}
 
-      fun startCPUTimer (): cpu_timer =
-         let
-            val {gc = {utime = gcu, stime = gcs, ...},
-                 self = {utime = selfu, stime = selfs}, ...} =
-               MLtonRusage.rusage ()
+      val startCPUTimer : unit -> cpu_timer =
+         let 
+            val () = MLtonGC.setRusage true
          in
-            {gc = SysUsr.T {sys = gcs, usr = gcu},
-             self = SysUsr.T {sys = selfs, usr = selfu}}
+            fn () =>
+            let
+               val {gc = {utime = gcu, stime = gcs, ...},
+                    self = {utime = selfu, stime = selfs}, ...} =
+                  MLtonRusage.rusage ()
+            in
+               {gc = SysUsr.T {sys = gcs, usr = gcu},
+                self = SysUsr.T {sys = selfs, usr = selfu}}
+            end
          end
 
       fun checkCPUTimes {gc, self} =