Skip to content

Core annotations

Jean Bisutti edited this page Jun 22, 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)

@ExpectMaxExecutionTime

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

πŸ”§ Parameters

Parameter 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 Nuumber of hours 0

You can use several parameters 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), @DisableSameSelectTypesWithDifferentParams
             Class specifying global annotations: org.quickperf.QuickPerfConfiguration

@DisableGlobalAnnotations

Disable global annotations on test method or test class.

πŸ”§ Parameters

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

@DisableQuickPerf

Disable QuickPerf features.

πŸ”§ Parameters

Parameter 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 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