Annotation Type AuxCounters


  • @Target(TYPE)
    @Retention(RUNTIME)
    public @interface AuxCounters

    AuxCounters annotation can be used to mark State objects as the bearers of auxiliary secondary results. Marking the class with this annotation will make JMH to treat its public fields and result-returning public methods as the base for the secondary benchmark metrics.

    Properties:

    • Auxiliary counters are not available for every BenchmarkMode, because not every mode counts time or operations. Mode.AverageTime and Mode.Throughput are always supported.
    • AuxCounters annotation is only available for Scope.Thread state objects. It is a compile-time error to use it with other states. This means the counters are thread-local in nature.
    • Only public fields and methods are considered as metrics. If you don't want a field/method to be captured as metric, do not make it public.
    • Only numeric fields and numeric-returning methods are considered as metrics. These include all primitives and their corresponding boxed counterTypes, except boolean/Boolean and char/Character. It is a compile-time error to use the public field/method with incompatible type.
    • Methods with void return type are exempted from type checking. This means helper Setup and TearDown methods are fine in AuxCounters.
    • Public fields in AuxCounters instances would be reset before starting the iteration, and read back at the end of iteration. This allows benchmark code to avoid complicated lifecycle handling for these objects.
    • The counter names are generated from field/method names. The namespace for counters is shared across all states participating in the run. JMH will fail to compile the benchmark if there is an ambiguity around what counter comes from what AuxCounters class.

    CAVEAT: THIS IS AN EXPERIMENTAL API, it may be changed or removed in future without prior warning. This is a sharp tool, use with care.

    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      AuxCounters.Type value  
    • Element Detail

      • value

        AuxCounters.Type value
        Default:
        org.openjdk.jmh.annotations.AuxCounters.Type.OPERATIONS