Skip to content

Core annotations

Jean Bisutti edited this page Jul 2, 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: 5 s 289 ms (5 289 245 600 ns)

⚠️ Be cautious with time measurement results. It is a rough and first level result. Data has no meaning below the ~second/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 ~second/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
hours int Number of hours 0
minutes int Number of minutes 0
seconds int Number of seconds 0
milliSeconds int Number of milli seconds 0

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

πŸ”Ž Example

@ExpectMaxExecutionTime(seconds = 2)
[PERF] Execution time of test method expected to be less than <2 s> but is <5 s 286 ms (5 285 734 000 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.expectMaxExecutionTimeOfSeconds(1)

        );

    }

}

⚠️ 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