Created
February 8, 2016 18:43
-
-
Save cameronpresley/eddd0b074d9840aa486b to your computer and use it in GitHub Desktop.
Performance Logger - Computational Expression that logs how long a function ran
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.Diagnostics | |
open System.Threading | |
type PerformanceLogger (printer:string -> unit) = | |
member this.Bind(x, func) = | |
let stopWatch = new Stopwatch() | |
stopWatch.Start () | |
func x | |
stopWatch.Stop () | |
printer (sprintf "Took %i seconds to run %A" (stopWatch.ElapsedMilliseconds/1000L) (func)) | |
member this.Zero () = () | |
member this.Return x = x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment