Annotation Type OperationsPerInvocation


@Inherited @Target({METHOD,TYPE}) @Retention(RUNTIME) public @interface OperationsPerInvocation

OperationsPerInvocation annotations allows to communicate the benchmark does more than one operation, and let JMH to adjust the scores appropriately.

For example, a benchmark which uses the internal loop to have multiple operations, may want to measure the performance of a single operation:

 @Benchmark
 @OperationsPerInvocation(10)
 public void test() {
      for (int i = 0; i < 10; i++) {
          // do something
      }
 }
 

This annotation may be put at Benchmark method to have effect on that method only, or at the enclosing class instance to have the effect over all Benchmark methods in the class.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    int
     
  • Element Details

    • value

      int value
      Returns:
      Number of operations per single Benchmark call.
      Default:
      1