如何测量F#代码的CPU和内存使用率? [英] How to measure CPU and memory usage of F# code?

查看:90
本文介绍了如何测量F#代码的CPU和内存使用率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是F#语言的新手,目前我正在对F#的性能进行简短的研究.所以我想做的是对我的F#代码进行基准测试.我已经找到了Stopwatch类,这很明显,但是对于其余您应该可以测试的类,我没有找到明确的线索.

I'm new to the language F# and currently I'm doing a short study on the F# performance. So what I would like to do is benchmark my F# code. I've already found the Stopwatch class, which was pretty obvious, but as for the rest of what you should be able to test, I found no clear leads.

我希望做的是在运行F#代码时找出其内存和cpu的使用情况.这里有没有人可以给我一些建议呢?

What I would wish to do is to find out memory and cpu usage of the F# code when I run it. Is there anyone here that might be able to give me some advices on how to do this?

推荐答案

对于快速原型制作,fsi的计时指令提供了很好的指示:

For quick prototyping, fsi's timing directive provides good indications:

#if INTERACTIVE
#time "on"
#endif

它打印出类似以下内容的内容:

It prints out something like:

Real: 00:00:00.199, CPU: 00:00:00.120, GC gen0: 0, gen1: 0, gen2: 0 

除执行时间外,其他统计信息还显示了在世代GC的三个级别中收集的垃圾量,这有助于了解程序中的内存使用情况.

Beside execution time, other statistics show amounts of garbage collected in three levels of the generational GC, which are helpful to understand memory usage in your programs.

对于严格的基准测试,您应该使用 Visual Studio探查器提供函数调用计数,时序和内存分配度量等,甚至使用第三方内存分析器.您可以在 Good F#Performance Profiling Tool 中找到一些使用这些分析器的提示. .

For serious benchmarking, you should use Visual Studio profiler which provides function call counts, timing, and memory allocation measurement, etc or even use third-party memory profilers. You can find some hints of using these profilers in my answer at Good F# Performance Profiling Tool.

这篇关于如何测量F#代码的CPU和内存使用率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆