src/Pure/ML-Systems/cpu-timer-basis.ML
changeset 14519 4ca3608fdf4f
child 14979 245955f0c579
equal deleted inserted replaced
14518:c3019a66180f 14519:4ca3608fdf4f
       
     1 (*  Title:      Pure/ML-Systems/cpu-timer-basis.ML
       
     2     ID:         $Id$
       
     3     Author:     Sebastian Skalberg (TU Muenchen)
       
     4 
       
     5 Implementation of timing functions, building on standard ("basis library") functions.
       
     6 *)
       
     7 
       
     8 (*Note start point for timing*)
       
     9 fun startTiming() =
       
    10   let val CPUtimer = Timer.startCPUTimer();
       
    11       val time = Timer.checkCPUTimer(CPUtimer)
       
    12   in  (CPUtimer,time)  end;
       
    13 
       
    14 (*Finish timing and return string*)
       
    15 fun endTiming (CPUtimer, {sys,usr}) =
       
    16   let open Time  (*...for Time.toString, Time.+ and Time.- *)
       
    17       val {sys=sys2,usr=usr2} = Timer.checkCPUTimer(CPUtimer)
       
    18   in  "User " ^ toString (usr2-usr) ^
       
    19       "  All "^ toString (sys2-sys + usr2-usr) ^
       
    20       " secs"
       
    21       handle Time => ""
       
    22   end;
       
    23