I am interested in this question and have tried a couple of things.
Generally one can use products such as JProfiler or VisualVM to perform a profiling of CPU and search for the methods that under investigation.
Also, one may use libraries such as JETM, CodaHale Metrics, or Netflix Servo to introduce measuring points in the application. However, the issue with this approach is that for third-party libraries it may not work because the libraries expect you to introduce measuring points inside the application. This is the most interesting approach for me since they are minimal in the amount of code they introduce.
Last but not least, one may also use approached based on AOP such as Spring AOP to measure specific executions of third party libraries. Since the project is not using AOP at all, I'd rather not introduce new dependencies for the only purpose of this measurement.
In my case, for instance, I would like to measure the execution of logging methods such as the mixture of JCL Log and log4j Logger implementation. I would like to use a JUnit RunListener with Maven Surefire and measure this execution for all the unit tests that I have.
So, any ideas? I'd appreciate suggestions.