-
Notifications
You must be signed in to change notification settings - Fork 4
Core annotations
@MeasureExecutionTime
@ExpectMaxExecutionTime
@DisplayAppliedAnnotations
@DisableGlobalAnnotations
@DisableQuickPerf
@FunctionalIteration
@DebugQuickPerf
Configure core annotations with a global scope
Measure execution time of test method.
[QUICK PERF] Execution time of test method: 1 s 1 ms (1 001 016 700 ns)
The test will fail if the execution time is greater than expected.
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.
@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)>
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.
[QUICK PERF] Applied annotations: @JdbcBatches(batchSize=30), @DisableSameSelectTypesWithDifferentParams
Class specifying global annotations: org.quickperf.QuickPerfConfiguration
Disable global annotations on test method or test class.
Parameter | Type | Meaning | Default value |
---|---|---|---|
comment | String | Comment why global annotations are disabled | - |
Disable QuickPerf features.
Parameter | Type | Meaning | Default value |
---|---|---|---|
comment | String | Comment why QuickPerf is disabled | - |
Disable QuickPerf features.
This annotation is addressed to developers working on QuickPerf annotations.
It displays information in console for debugging purpose.
Annotations having a global scope apply on each test. org.quickperf.annotation.CoreAnnotationBuilder
helps configure core annotations with a global scope.
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.
π Β Core
π Β JVM
π Β SQL
π Β Scopes
π Β Create an annotation
π Β JUnit 4
π Β JUnit 5
π Β TestNG
π Β Spring
π Β Detect and fix N+1 SELECT
π Β Maven performance
π Β Spring Boot - JUnit 4
π Β Spring Boot - JUnit 5
π Β Micronaut Data - JUnit 5
π Β Micronaut - Spring - JUnit 5
π Β Quarkus - JUnit 5
π Β FAQ
π Β QuickPerf code