chore(test): add module for jmh benchmarks

This commit is contained in:
Florian Hussonnois
2025-05-21 22:03:56 +02:00
committed by Florian Hussonnois
parent 593aad2aea
commit 55740133f0
4 changed files with 73 additions and 1 deletions

17
jmh-benchmarks/README.md Normal file
View File

@@ -0,0 +1,17 @@
# JMH-Benchmarks module
This module contains benchmarks written using JMH from OpenJDK.
## Running Benchmarks
**To run all benchmarks**
```bash
./gradlew jmh:jmh
```
**To run a specific benchmark**
```bash
./gradlew jmh:jmh -Pjmh.include=io.kestra.core.utils.MapUtilsBenchmark
```

View File

@@ -0,0 +1,22 @@
plugins {
id "me.champeau.jmh" version "0.7.2"
}
configurations {
tests
implementation.extendsFrom(micronaut)
}
tasks.register('copyGradleProperties', Copy) {
group = "build"
shouldRunAfter compileJava
from '../gradle.properties'
into 'src/main/resources'
}
processResources.dependsOn copyGradleProperties
dependencies {
jmh project(':core')
}

View File

@@ -0,0 +1,32 @@
package io.kestra.core.utils;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.*;
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@State(Scope.Thread)
public class MapUtilsBenchmark {
private Map<String, Object> mapA;
private Map<String, Object> mapB;
@Setup(Level.Invocation)
public void setup() {
mapA = new HashMap<>();
mapB = new HashMap<>();
for (int i = 0; i < 100; i++) {
mapA.put("key" + i, "valueA" + i);
mapB.put("key" + i, "valueB" + i);
}
mapA.put("nested", Map.of("a", 1));
mapB.put("nested", Map.of("b", 2));
}
@Benchmark
public Map<String, Object> testMerge() {
return MapUtils.merge(mapA, mapB);
}
}

View File

@@ -1,4 +1,4 @@
rootProject.name="kestra"
rootProject.name = "kestra"
include 'platform'
@@ -24,3 +24,4 @@ include 'processor'
include 'script'
include 'e2e-tests'
include 'jmh-benchmarks'