Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Profiler for Mata

    Hello,

    I'm currently writing a package and I have some performance issues. To investigate the issue, I've used the Mata timer() functions, to understand where the time is spent.

    However, my code is a bit recursive and I wanted to understand the chain of calls between the functions. For this, I like to use profilers in other languages and combine it with flame graphs to visualize the results.

    I know of the profiler command for Stata, but I couldn't find a profiler for Mata, so I've tried to do my own implementation in Mata. For that, I measure the time at the beginning and the end of each function with timer_on(), timer_off() and timer_value(), and keep track of the order of calls to see which function is calling which one. It works, I like it, but it's slow and adds overhead to each function call, which bias the time measures. For example, some functions appear to take a lot of time overall, just because they are called frequently with this overhead.

    Here are the kind of call trees and flamegraph I have right now.

    Do you know of any function or command that exist that does similar profiling of Mata code?

    Best,
    Mael Astruc--Le Souder
Working...
X