mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-23 21:04:39 -05:00
chore(test): add module for jmh benchmarks
This commit is contained in:
committed by
Florian Hussonnois
parent
593aad2aea
commit
55740133f0
17
jmh-benchmarks/README.md
Normal file
17
jmh-benchmarks/README.md
Normal 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
|
||||
```
|
||||
22
jmh-benchmarks/build.gradle
Normal file
22
jmh-benchmarks/build.gradle
Normal 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')
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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'
|
||||
Reference in New Issue
Block a user