Actually you can already do this, just without the clicks and forms.

Highlight your code and press Alt+Enter to send it to FSI. In the FSI window type the following:

1
> #time;;

Now invoke your function, and at the end it will output statistics about GC collections and execution time. If you want to do it 1,000 times instead of 1, type the following:

1
Seq.iter (fun _ -> my_func arg1 arg2 (*etc*)) [1..1000]

and the statistics will be about all 1,000 executions

By on 2/24/2009 2:27 PM ()

Brilliant, great stuff!

Thanks a lot,

dfg

By on 2/24/2009 2:33 PM ()

If you want to understand why your code runs slow or fast, use Reflector to have a look at what it compiles to. For simple stuff the number of heap allocations is often a good measure for comparing the relative performance of two code snippets doing the same work.

By on 2/24/2009 2:50 PM ()

A note of caution: beware measurements of anything other than Release-mode optimized code. Measuring well is not always trivial.

By on 2/24/2009 2:39 PM ()

A note of caution: beware measurements of anything other than Release-mode optimized code. Measuring well is not always trivial.

That reminds me. In the Visual Studio Project options, there's a way to specify "compilation flags" for F# interactive. One of the default ones is --optimize. Does this mean that FSI code is already release optimized?

By on 2/24/2009 3:01 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper