Profiling a brms model with cmdstan

I would like to apply this Cmdstan profiling vignette directly within the brm function.

Although I suppose I could save the generated stancode to a separate file. insert the profiling references myself, and call cmdstan directly, one thread suggested this could be accomplished directly in the brm function by adding language to stanvars, but one poster suggested it might only work for simple models.

Can anyone suggest what this additional language might look like if added to the brm function, perhaps to accomplish the same profiling being done in the hyperlinked vignette? And do others concur that this only would likely work with simpler, likely univariate outcomes?

Thank you.

The language added via stanvars would be profile("some informative string") { and }. The challenge is inserting it precisely around the statements that you want to profile. Currently with brms, this would be sufficient to profile, for example, the likelihood (see User-defined variables passed to Stan — stanvar • brms) but not to profile specific lines of code. This would work irrespective of the model complexity, but in complex models it might tend to be the case that we could benefit from more fine-grained profiling capabilities.