summaryrefslogtreecommitdiff
path: root/src/nbc/stopwatch.sml
diff options
context:
space:
mode:
authorCalvin <calvin@EESI>2013-03-15 15:26:20 -0400
committerCalvin <calvin@EESI>2013-03-15 15:26:20 -0400
commitb632667ce57af89691407bb8668e1512775278ae (patch)
treeb5742cef185f1cc4a7ba6005b5b4116ce7558a01 /src/nbc/stopwatch.sml
parent39e39f82cc38d71018882b0aaaf58255858a7c56 (diff)
nbc added
Diffstat (limited to 'src/nbc/stopwatch.sml')
-rw-r--r--src/nbc/stopwatch.sml24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/nbc/stopwatch.sml b/src/nbc/stopwatch.sml
new file mode 100644
index 0000000..43547ed
--- /dev/null
+++ b/src/nbc/stopwatch.sml
@@ -0,0 +1,24 @@
+signature STOPWATCH = sig
+ exception FinishWithoutStart
+ val start: string -> unit
+ val finish: unit -> unit
+end
+structure Stopwatch :> STOPWATCH = struct
+ exception FinishWithoutStart
+ local
+ val time = ref NONE
+ in
+ fun start doing = (
+ print (concat [doing, "..."])
+ ; time := SOME (Time.now ())
+ )
+ fun finish () = case !time of
+ SOME t => (
+ print (concat [
+ " done in "
+ , Time.toString (Time.- (Time.now (), t))
+ , " seconds.\n"
+ ]); time := NONE
+ ) | NONE => raise FinishWithoutStart
+ end
+end