aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Maven - Performance profiling of code executed by JUNIT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Maven - Performance profiling of code executed by JUNIT" Watch "Maven - Performance profiling of code executed by JUNIT" New topic
Author

Maven - Performance profiling of code executed by JUNIT

Anish Pyne
Greenhorn

Joined: Aug 23, 2010
Posts: 15
Is there any maven plugin available which can be used to profile the performance / execution time of the entire chain of APIs/code that gets run during a JUNIT execution.

E.g. If JUNIT is run on methodA() which calls methodB() which calls methodC() I want the full time breakup as

Total time for methodA
...Total time for methodB
.....Total time for methodC

I want a report generated so that it can be included for "site" phase.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5837
    
    7

None that I know. But an option to give the timing for methodA (in your example) should be easy enough to add to the Surefire plugin. Getting the timings of the other methods would require some Aspect programming.


JBoss In Action
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5837
    
    7

Silly me. I looked at the site generated by Maven for one of my projects and guess what? The Surefire Report already shows the timings for each unit test case. Of course, that is the timing for the unit test case method, which is the method that would call methodA in your example.

But I thought a little further on this issue, and while unit test timing my be a quick and dirty way to get some performance numbers, the numbers are probably meaningless. For several reasons.

First, calling a series of methods only once can result in a large variation of results between one build and the next. There are just too many variables with bootstrapping an application to count on perf numbers obtained at that time. In typical perf testing, you have a warm-up phase phase, a steady state phase, and a ramp down phase. Only the timings during the steady state phase have any meaning.

Second, unit tests are single threaded. So you will have no idea of how things performed under stress, or even under normal usage.

Overall, if you want performance numbers, incorporate JMeter or some similar tool into your build and let it gather perf data for you.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Maven - Performance profiling of code executed by JUNIT