How to measure CPU usage and F # code memory?

I am new to F # and am currently doing a short research on F # performance. So, what I would like to do is compare my F # code. I already found a stopwatch class that was pretty obvious, but as for the rest of the test, I did not find clear results.

What I would like to do is to learn how to use memory and use F # code when I run it. Is there anyone here who could give me some tips on how to do this?

+8
source share
2 answers

For rapid prototyping, the fsi sync directive provides good readings:

#if INTERACTIVE #time "on" #endif 

It prints something like:

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

In addition to runtime, other statistics show the amount of garbage collected at the three levels of the GC generation, which is useful for understanding the memory usage of your programs.

For serious benchmarking, you should use the Visual Studio Profiler , which provides function call counting, time and memory allocation, etc. or even using third-party memory profiles. You can find some tips on using these profilers in my answer in the Good F # Performance Profiling Tool .

+10
source

You can also find this blog post from Dave Thomas (formerly Moirae Software) useful:

https://7sharp9.imtqy.com/2011/12/11/2011-12-11-fixing-a-hole/

I usually define a specific part of a blog post that I think answers the question, but the entire blog post is the answer to this question.

EDIT: Updated link because the old link was broken.

+2
source

All Articles