Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Maven - Performance profiling of code executed by JUNIT

 
Anish Pyne
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic