Good F# Performance Profiling Tool

My answer may disappoint you, but it might be helpful.

A few months ago, I tried to find a good free .NET profiler for my F# project. My experience with nprof, slimtune, EQATEC and (recently commercial) Xte profiler was not decent at all. I found their support for F# was very limited, and had to fall back to Visual Studio 2010 profiler. I think your best bet here is some commercial profiler (which I have no experience with).

After some time, I get used to the profiler and see its presentation of results easy, clear and understandable. If you were optimizing parallel programs, using the Concurrent Visualizer would be unavoidable. That said the single thing you care is performance; getting on well with VS 2010 profiler is worth to try.

For profiling F# code, I also find CLR Profiler and ILSpy worth to mention. The former can visualize heaps in case you want to minimalize memory allocation or garbage collection. The latter can produce equivalent code in IL or C# (which I'm more familiar with than F#); it may help to understand how high-order constructs in F# work in order to use them appropriately.

UPDATE:

Dave Thomas has written an excellent blog post where he used several commercial profilers to detect memory leaks and tune an asynchronous application. Take a look at those profilers; they may suit your preference.


It sounds like your profiling in Debug mode. You need to enable "Optimize code" from project -> properties -> build menu. You could also profile in release mode which has this enabled by default. If you don't there will be lots of invoke calls and Tuple object creation among other things.

The MultiAdd function above is not tail recursive. If it were, you would also need to enable "Generate tail calls" in Debug mode for profiling.

enter image description here

This would also be a good case for tail call optimization.

let Add a b = 
    a + b

let Add1 = Add 1

let rec MultiAdd total count =
    match count with
    | 1 -> 1 + total
    | _ -> MultiAdd (count - 1) (total + Add1 1)

MultiAdd 10000 0 |> ignore

enter image description here