Is anybody aware of programs for profiling OCaml code apart from using the -p option while compilation and then using gprof? I am asking this question in order to check if the sampling time of 0.01 second can be lowered further?
            Asked
            
        
        
            Active
            
        
            Viewed 2,181 times
        
    16
            
            
        - 
                    1*[This technique](http://stackoverflow.com/questions/375913/what-can-i-use-to-profile-c-code-in-linux/378024#378024)* works with ocaml as well, I believe. – Mike Dunlavey Feb 08 '12 at 13:53
- 
                    [Profiling OCaml code](https://github.com/ocaml-bench/notes/blob/master/profiling_notes.md) has a lot of useful information, including topics such as: - perf record - gprof - callgrind - landmarks - statmemprof – Thomas Leonard Oct 29 '20 at 10:59
- 
                    [poorman's profiler]( http://poormansprofiler.org/) is perfectly applicable for OCaml programs. The same idea works out for [profiling allocations](https://sympa.inria.fr/sympa/arc/caml-list/2011-08/msg00050.html) as well. – ygrek Feb 08 '12 at 11:57
3 Answers
6
            
            
        You can also use ocaml-memprof, a compiler patch (3.12.0 and 3.12 1) written by Fabrice Le Fessant, that adds memory profiling features to ocaml programs.
EDIT
Now you have ocp-memprof, an OCaml Memory Profiler that you can use online. It is available on http://memprof.typerex.org.
 
    
    
        Çağdaş Bozman
        
- 2,537
- 16
- 21
2
            
            
        Adding to the list of useful answers: this OCamlPro post mentions performance profiling (not memory profiling) of native code on Linux using perf (installed via package linux-tools in Debian-like distributions).
Basically, you just need to run:
perf record -g ./native_program arguments
To produce a perf.data file containing profiling data, and then run
perf report -g
To see the results.
It works better when using an OCaml release with frame pointers enabled (e.g. 4.02.1+fp instead of 4.02.1 on OPAM).
 
     
     
     
    