First commit of the f# source code.
[master-thesis.git] / Parasitemia / Parasitemia / Utils.fs
diff --git a/Parasitemia/Parasitemia/Utils.fs b/Parasitemia/Parasitemia/Utils.fs
new file mode 100644 (file)
index 0000000..de16664
--- /dev/null
@@ -0,0 +1,19 @@
+module Utils
+
+open System.Diagnostics
+
+let roundInt = int << round
+
+let inline dprintfn fmt =
+    Printf.ksprintf System.Diagnostics.Debug.WriteLine fmt
+
+let mutable log : (string -> unit) =
+    fun m -> ()
+
+let logTime (m: string) (f: unit -> 'a) : 'a =
+    let sw = Stopwatch()
+    sw.Start()
+    let res = f ()
+    sw.Stop()
+    log <| sprintf "%A (time: %A ms)" m sw.ElapsedMilliseconds
+    res 
\ No newline at end of file