Good F# Performance Profiling Tool

后端 未结 2 1244
我在风中等你
我在风中等你 2020-12-28 18:16

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

2条回答
  •  醉梦人生
    2020-12-28 18:46

    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

提交回复
热议问题