How to get cpu time used for a XWiki request

I am looking for a routine that will return the cpu time used so far when rendering a document.

(I want to speed up some of my macros.)

Thanks for help

When I need to do something like this, I generally use a profiler (in my case Yourkit because I have a license and I got used to it, but you can probably do this kind of detailed CPU profiling with something like VisualVM).

Another possibility if your request is very slow is to use something like Glowroot which highlight what happen during the slowest requests.

See also: