Skip to Content
Java EE 8 High Performance
book

Java EE 8 High Performance

by Romain Manni-Bucau
January 2018
Intermediate to advanced
350 pages
9h 7m
English
Packt Publishing
Content preview from Java EE 8 High Performance

Integrating JMH with JUnit

There is no official JUnit integration of JMH. In spite of that, it is not that hard to do it yourself. There are lots of possible designs, but in the context of this book we will do the following:

  • Our integration will go through a JUnit runner
  • The benchmark classes will be identified by extracting the nested classes of the test class which will avoid using any scanning to find the benchmark classes or explicit listing
  • We will introduce an @ExpectedPerformances annotation to be able to add assertions based on the execution

Structurally, a microbenchmark test using this structure will look like this:

@RunWith(JMHRunner.class)public class QuoteMicrobenchmarkTest {    @ExpectedPerformances(score = 2668993660.)    public ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java EE 8 Application Development

Java EE 8 Application Development

David R. Heffelfinger
Java 9 High Performance

Java 9 High Performance

Mayur Ramgir, Nick Samoylov
Java EE 8 Design Patterns and Best Practices

Java EE 8 Design Patterns and Best Practices

Rhuan Rocha, Joao Carlos Purificação

Publisher Resources

ISBN: 9781788473064Supplemental Content