src/Pure/ML-Systems/cpu-timer-basis.ML
author obua
Sun, 09 May 2004 23:04:36 +0200
changeset 14722 8e739a6eaf11
parent 14519 4ca3608fdf4f
child 14979 245955f0c579
permissions -rw-r--r--
replaced apply-style proof for instance Multiset :: plus_ac0 by recommended Isar proof style
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14519
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
     1
(*  Title:      Pure/ML-Systems/cpu-timer-basis.ML
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
     2
    ID:         $Id$
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
     3
    Author:     Sebastian Skalberg (TU Muenchen)
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
     4
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
     5
Implementation of timing functions, building on standard ("basis library") functions.
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
     6
*)
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
     7
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
     8
(*Note start point for timing*)
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
     9
fun startTiming() =
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
    10
  let val CPUtimer = Timer.startCPUTimer();
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
    11
      val time = Timer.checkCPUTimer(CPUtimer)
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
    12
  in  (CPUtimer,time)  end;
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
    13
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
    14
(*Finish timing and return string*)
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
    15
fun endTiming (CPUtimer, {sys,usr}) =
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
    16
  let open Time  (*...for Time.toString, Time.+ and Time.- *)
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
    17
      val {sys=sys2,usr=usr2} = Timer.checkCPUTimer(CPUtimer)
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
    18
  in  "User " ^ toString (usr2-usr) ^
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
    19
      "  All "^ toString (sys2-sys + usr2-usr) ^
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
    20
      " secs"
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
    21
      handle Time => ""
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
    22
  end;
4ca3608fdf4f Added support for the newer versions of SML/NJ, which break several of the
skalberg
parents:
diff changeset
    23