本文介绍了良好的 F# 性能分析工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能推荐一个具有良好 F# 支持的性能分析工具?

Can anyone recommend a performance profiling tool with good F# support?

我一直在使用 Visual Studio 2010 分析器,但在使用 F# 时发现了一些问题.感觉更像是我在反射后分析字节码而不是原始 F#.

I’ve been using Visual Studio 2010 profiler but I’ve found a few issues when using F#. It feels more like I’m profiling the byte code after reflection than the original F#.

例如,在分析以下稍微做作的示例时:

For example when profiling the following slightly contrived example:

let Add a b =
    a + b

let Add1 = Add 1

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

MultiAdd 10000 |> ignore

我得到以下调用树:

当我在函数详细信息中查看 Microsoft.FSharp.Core.FSharpFunc`2.Invoke(0) 时,我看到:

When I view Microsoft.FSharp.Core.FSharpFunc`2.Invoke(0) in the Function Details I see:

我知道我看到的是基于编译代码的底层实现,虽然我可以遵循它,但很难.

I understand that what I seeing is based on the underlying implementation of the compiled code and although I can follow it, it’s hard going.

有没有人有将其他分析工具与 F# 结合使用的经验,并且他们在映射到原始 F# 代码方面做得更好吗?

Does anyone have experience of using other profiling tools with F# and do they do a better job of mapping to the original F# code?

推荐答案

我的回答可能会让你失望,但可能会有所帮助.

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

几个月前,我试图为我的 F# 项目找到一个好的免费 .NET 分析器.我对 nprofslimtune, EQATECa> 和(最近商业化的)Xte profiler 一点也不像样.我发现他们对 F# 的支持非常有限,不得不退回到 Visual Studio 2010 分析器.我认为最好的选择是一些商业分析器(我没有使用过).

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).

一段时间后,我习惯了分析器,看到它的结果呈现简单、清晰和易于理解.如果您正在优化并行程序,则不可避免地要使用 Concurrent Visualizer.也就是说,您关心的唯一一件事就是性能;与 VS 2010 分析器相处得很好,值得一试.

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.

为了分析 F# 代码,我还找到了 CLR ProfilerILSpy 值得一提.如果您想最小化内存分配或垃圾收集,前者可以可视化堆.后者可以在 IL 或 C#(我比 F# 更熟悉)中生成等效代码;它可能有助于理解 F# 中的高阶构造如何工作以便正确使用它们.

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.

更新:

戴夫·托马斯写了 一篇优秀的博文,他使用了几个商业分析器来检测内存泄漏并调整异步应用程序.看看那些分析器;它们可能适合您的喜好.

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.

这篇关于良好的 F# 性能分析工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 08:57
查看更多