Profiling RStan Code with Apple Instruments or Similar

Is there any way to profile a Stan model that I run using RStan ?

I’m interested to see which C++ functions are called inside “sampling”. I have used the R profiling tool to capture this screenshot but it doesn’t allow me to see what is going on inside sampling.

In addition I tried to catch the R session with Apple Instruments but I couldn’t seem to get the right one. The trace I obtained does not show me what happens inside the sampling function. I was following these instructions when using Instruments:

Is there any easy way for me to see what is going on inside the sampling function and how much time is spent on each of the processes that go on inside it ?

I have attached the model I am trying to profile: golf_logistic.stan (135 Bytes) Golf.R (522 Bytes) golf_data.txt (196 Bytes)

1 Like

What is it you want to look at in particular? I tend to use linux’s perf or the clang’s instrumentation options for execution times and heaptrack for looking at heap memory allocations

Also for profiling Stan i think your better off using cmdstan

Thanks, cmdStan allows me to do what I want