Skip to content

Core annotations

Jean Bisutti edited this page Jul 19, 2020 · 52 revisions

🚩 Table of contents

@MeasureExecutionTime

@ExpectMaxExecutionTime

@DisplayAppliedAnnotations

@DisableGlobalAnnotations

@DisableQuickPerf

@FunctionalIteration

@DebugQuickPerf

Configure core annotations with a global scope

@MeasureExecutionTime

Measures the execution time of the test method.

πŸ”Ž Example

[QUICK PERF] Execution time of the 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 exceeds the maximum expected.

It can be useful to configure @ExpectMaxExecutionTime 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 @ExpectMaxExecutionTime elements together, as shown in the following example.

πŸ”Ž Example

@ExpectMaxExecutionTime(seconds = 2)
[PERF] Execution time of the test method expected to be less than <2 s> but is <5 s 286 ms (5 285 734 000 ns)>

@DisplayAppliedAnnotations

Displays applied QuickPerf annotations in the console.

An annotation can have three scopes (global, test class, test method). @DisplayAppliedAnnotations 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

Disables global annotations on test methods or test classes.

πŸ”§ Elements

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

@DisableQuickPerf

Disables QuickPerf features.

πŸ”§ Elements

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

@FunctionalIteration

Disables QuickPerf features.

@DebugQuickPerf

QuickPerf developers can use @DebugQuickPerf to display debugging information in the console.

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)

        );

    }

}

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