Search code examples
javabenchmarkingperformance-testingjmh

Using JMH as a framework for performance testing on functional/user level. Is it wrong?


I want to use JMH as a framework for performance testing on functional/user level for web application. Imagine me using JMH to, say, measure how long it takes from the moment when 100 users click "Post Your Question" on this site concurrently, to the moment when user sees their question posted.

Is this entirely wrong? What are the drawbacks of such approach?

  • I do not expect a nanosecond accuracy for those tests: half a second to a second accuracy are just fine.
  • I created a first realistic test, and really liked how it looked / worked - exactly what I need. But am I missing some big trouble ahead by using micro-benchmark framework for what it's not intended to do?
  • Not looking for tool recommendations

Solution

  • Now using this approach for approximately 6 months, I want to say that I still did not see any drawbacks. A few things I learned:

    • Even though on functional/user level of accuracy is lower, it's important to learn how various configuration parameters work (especially JVM-related, e.g. fork). They may influence how you build your tests, how do you run them, and what do you measure.
    • JMH is really lightweight and efficient, so comparing to the results obtained using other frameworks may not be valid (basically we saw 10-20% performance boost when running with JMH); I had to establish a new baseline.
    • JMH Jenkins plug-in helps with visualizing the results