Can anyone recommend a performance profiling tool with good F# support?
I’ve been using Visual Studio 2010 profiler but I’ve found a few issues when using F#. It fee
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.
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