Measure time of execution in F#

nanek picture nanek · Dec 24, 2010 · Viewed 14.1k times · Source

Please post code for displaying time in F#. I noticed that you can measure it from F# interactive with #time directive, but I don't know how to execute program from FSI

Thanks

Answer

BrokenGlass picture BrokenGlass · Dec 24, 2010

I would just use the .NET Stopwatch class.

let stopWatch = System.Diagnostics.Stopwatch.StartNew()
...
stopWatch.Stop()
printfn "%f" stopWatch.Elapsed.TotalMilliseconds