Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I time my sml code?

Can anyone tell me how I can time my sml code?

I have implemented several different versions of the same algorithm and would like to time them and perhaps even know the memoryusage?

like image 638
Martin Kristiansen Avatar asked Dec 01 '11 10:12

Martin Kristiansen


1 Answers

The Timer module is what you want. It can either give you cpu time (gives you user, sys and gc times) or wall clock time.

For example of how to use it see the Benchmark module of MyLib.

With respect to finding out how much memory your algorithms are using, you might bind the profiling feature of MLton handy. Note however that i have actually never used this, but it states that:

you can profile your program to find out how many bytes each function allocates.

like image 182
Jesper.Reenberg Avatar answered Nov 05 '22 23:11

Jesper.Reenberg