The state

Once you have the right dependencies, you can develop your benchmarks. The API is quite straightforward. It uses the notion of a state and a state has a life cycle and (volatile) storage associated with the benchmark. The life cycle of a state is defined by marking methods with:

  • @Setup to execute an initialization task
  • @Teardown to release any created resource in the setup method

State classes can also contain fields decorated with @Param to make them contextualized and configurable (such as enabling them to get a different target URL depending on the execution for example).

A state class is marked with @State, which takes, as parameter, the scope of the state instance for a benchmark:

  • Benchmark means the state will be a singleton ...

Get Java EE 8 High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.