Skip to content

Core annotations

Jean Bisutti edited this page Jun 25, 2020 · 52 revisions

🚩 Table of contents

@MeasureExecutionTime

@ExpectMaxExecutionTime

@DisplayAppliedAnnotations

@DisableGlobalAnnotations

@DisableQuickPerf

@FunctionalIteration

@DebugQuickPerf

Configure core annotations with a global scope

@MeasureExecutionTime

Measure execution time of test method.

πŸ”Ž Example

[QUICK PERF] Execution time of test method: 1 s 1 ms (1 001 016 700 ns)

⚠️ Be cautious with time measurement results. It is a rough and first level result. Data has no meaning below the seconde / millisecond. JIT warm up, GC or safe points can impact the measure and its reproducibility. We recommend JMH to do more in depth experiments.

@ExpectMaxExecutionTime

The test will fail if the execution time is greater than expected.

It can be useful to configure this annotation with a global scope.

⚠️ Be cautious with time measurement results. It is a rough and first level result. Data has no meaning below the seconde / millisecond. JIT warm up, GC or safe points can impact the measure and its reproducibility. We recommend JMH to do more in depth experiments.

πŸ”§ Elements

Name Type Meaning Default value
nanoSeconds long Number of nano seconds 0
microSeconds long Number of micro seconds 0
milliSeconds int Number of milli seconds 0
seconds int Number of seconds 0
minutes int Number of minutes 0
hours int Number of hours 0

You can use several elements together, as shown in the following example.

πŸ”Ž Example

@ExpectMaxExecutionTime(seconds = 1, milliSeconds = 10)
[PERF] Execution time of test method expected to be less than <1 s 10 ms> but is <9 s 502 ms (9 501 875 600 ns)>

@DisplayAppliedAnnotations

Display applied QuickPerf annotations in console.

An annotation can have three scopes (gobal, test class, test method). This annotation is useful to see which annotations are applied on a test method.

πŸ”Ž Example

[QUICK PERF] Applied annotations: @JdbcBatches(batchSize=30), @DisableSameSelectTypesWithDifferentParamValues
             Class specifying global annotations: org.quickperf.QuickPerfConfiguration

@DisableGlobalAnnotations

Disable global annotations on test method or test class.

πŸ”§ Elements

Name Type Meaning Default value
comment String Comment why global annotations are disabled -

@DisableQuickPerf

Disable QuickPerf features.

πŸ”§ Elements

Name Type Meaning Default value
comment String Comment why QuickPerf is disabled -

@FunctionalIteration

Disable QuickPerf features.

@DebugQuickPerf

This annotation is addressed to developers working on QuickPerf annotations.
It displays information in console for debugging purpose.

Configure core annotations with a global scope

Annotations having a global scope apply on each test.

org.quickperf.annotation.CoreAnnotationBuilder helps to configure core annotations with a global scope.

πŸ”Ž Example

package org.quickperf;

import org.quickperf.annotation.CoreAnnotationBuilder;
import org.quickperf.config.SpecifiableGlobalAnnotations;

import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.Collection;

public class QuickPerfConfiguration implements SpecifiableGlobalAnnotations {

    public Collection<Annotation> specifyAnnotationsAppliedOnEachTest() {

        return Arrays.asList(
          
                CoreAnnotationBuilder.expectMaxExecutionTimeOfMilliSeconds(500)

        );

    }

}

⚠️ The class implementing SpecifiableGlobalAnnotations has to be in org.quickperf package.

Annotations

πŸ‘‰ Β Core

πŸ‘‰ Β JVM

πŸ‘‰ Β SQL

πŸ‘‰ Β Scopes

πŸ‘‰ Β Create an annotation

Supported frameworks

πŸ‘‰ Β JUnit 4

πŸ‘‰ Β JUnit 5

πŸ‘‰ Β TestNG

πŸ‘‰ Β Spring

How to

πŸ‘‰ Β Detect and fix N+1 SELECT

Project examples

πŸ‘‰ Β Maven performance

πŸ‘‰ Β Spring Boot - JUnit 4

πŸ‘‰ Β Spring Boot - JUnit 5

πŸ‘‰ Β Micronaut Data - JUnit 5

πŸ‘‰ Β Micronaut - Spring - JUnit 5

πŸ‘‰ Β Quarkus - JUnit 5

Miscellaneous

πŸ‘‰ Β FAQ

πŸ‘‰ Β QuickPerf code

Clone this wiki locally