Skip to content

Commit

Permalink
feat: roll back benchmarks to use deprecated way of setting config so…
Browse files Browse the repository at this point in the history
…urces.

Add script to run benchmark with parameters.
  • Loading branch information
credmond-git committed Mar 17, 2024
1 parent 437084c commit e480d7d
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 17 deletions.
13 changes: 13 additions & 0 deletions benchmark.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$gestaltVersions = @("0.25.0", "0.24.6", "0.24.5", "0.24.4", "0.24.3", "0.24.2", "0.24.1", "0.24.0", "0.23.3", "0.23.2", "0.23.1", "0.23.0", "0.22.1", "0.21.0", "0.20.6", "0.20.5", "0.20.4", "0.20.3", "0.20.2", "0.20.1", "0.19.0", "0.18.0", "0.16.6", "0.16.5", "0.16.4", "0.16.3", "0.16.2", "0.16.1", "0.16.0", "0.15.0", "0.14.1", "0.14.0", "0.13.0", "0.12.0")
#$gestaltVersions = @("0.25.0", "0.24.6")
#jdkVersions = @(11 17 21)
$jdkVersions = @(11)

foreach ($jdkVersion in $jdkVersions)
{
foreach ($gestaltVersion in $gestaltVersions)
{
$gradleCommand = "./gradlew jmh -PgestaltVersion=`"$gestaltVersion`" -PjdkVersion=`"$jdkVersion`""
Invoke-Expression $gradleCommand
}
}
14 changes: 14 additions & 0 deletions benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

#gestalt_versions=(0.25.0 0.24.6 0.24.5 0.24.4 0.24.3 0.24.2 0.24.1 0.24.0 0.23.3 0.23.2 0.23.1 0.23.0 0.22.1 0.21.0)
gestalt_versions=(0.25.0 0.24.6)
#jdk_version=(11 17 21)
jdk_version=(11)

for jdk in ${jdk_version[@]}
do
for v in ${gestalt_versions[@]}
do
./gradlew jmh -DgestaltVersion=$v -DjdkVersion=$jdk
done
done
28 changes: 23 additions & 5 deletions gestalt-benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,44 @@ repositories {
mavenCentral()
}

var gestaltVersion: String = if (project.hasProperty("gestaltVersion")) {
project.property("gestaltVersion") as String
} else if (System.getProperty("gestaltVersion") != null) {
System.getProperty("gestaltVersion")
} else {
libs.versions.gestalt.get()
}

var jdkVersion: Int = if (project.hasProperty("jdkVersion")) {
Integer.parseInt(project.property("jdkVersion") as String)
} else if (System.getProperty("jdkVersion") != null) {
Integer.parseInt(System.getProperty("jdkVersion"))
} else {
Integer.parseInt(libs.versions.java.get())
}

println("Running benchmarks with Gestalt Version: $gestaltVersion and JDK $jdkVersion")

dependencies {
jmh(libs.jmh)
jmh(libs.jmh.annotations)

// this is the line that solves the missing /META-INF/BenchmarkList error
jmhAnnotationProcessor(libs.jmh.annotations)

implementation(libs.gestalt.core)
implementation(libs.gestalt.kotlin)
implementation("com.github.gestalt-config:gestalt-core:${gestaltVersion}")
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
languageVersion.set(JavaLanguageVersion.of(jdkVersion))
}
}

jmh {
// setup
failOnError.set(true)
resultsFile.set(File("${project.projectDir}/results/results-${libs.versions.gestalt.get()}.json"))
resultsFile.set(File("${project.projectDir}/results/results-${gestaltVersion}-jdk-${jdkVersion}.json"))
resultFormat.set("JSON")

// Warmup
Expand All @@ -38,7 +55,8 @@ jmh {
// Benchmarks
fork.set(2)
iterations.set(5)
timeOnIteration.set("5s")
timeOnIteration.set("10s")


jvmArgs.set(listOf("-Xmx1G", "-Xms1G", "-XX:+UseG1GC"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import org.github.gestalt.config.Gestalt;
import org.github.gestalt.config.builder.GestaltBuilder;
import org.github.gestalt.config.exceptions.GestaltException;
import org.github.gestalt.config.source.ClassPathConfigSourceBuilder;
import org.github.gestalt.config.source.MapConfigSourceBuilder;
import org.github.gestalt.config.source.ClassPathConfigSource;
import org.github.gestalt.config.source.MapConfigSource;
import org.openjdk.jmh.annotations.*;

import java.util.HashMap;
Expand All @@ -22,6 +22,7 @@
* @author <a href="mailto:colin.redmond@outlook.com"> Colin Redmond </a> (c) 2024.
*/

@SuppressWarnings("deprecation")
public abstract class Benchmarks {

@Benchmark
Expand Down Expand Up @@ -58,9 +59,9 @@ public Gestalt GestaltConfig_Setup(BenchmarkState state) throws GestaltException
// The later ones layer on and over write any values in the previous
GestaltBuilder builder = new GestaltBuilder();
Gestalt gestalt = builder
.addSource(ClassPathConfigSourceBuilder.builder().setResource("/default.properties").build())
.addSource(ClassPathConfigSourceBuilder.builder().setResource("/dev.properties").build())
.addSource(MapConfigSourceBuilder.builder().setCustomConfig(configs).build())
.addSource(new ClassPathConfigSource("/default.properties"))
.addSource(new ClassPathConfigSource("/dev.properties"))
.addSource(new MapConfigSource(configs))
.build();

// Load the configurations, this will throw exceptions if there are any errors.
Expand Down Expand Up @@ -97,19 +98,19 @@ public void setup() throws GestaltException {
// The later ones layer on and over write any values in the previous
GestaltBuilder builder = new GestaltBuilder();
gestalt = builder
.addSource(ClassPathConfigSourceBuilder.builder().setResource("/default.properties").build())
.addSource(ClassPathConfigSourceBuilder.builder().setResource("/dev.properties").build())
.addSource(MapConfigSourceBuilder.builder().setCustomConfig(configs).build())
.addSource(new ClassPathConfigSource("/default.properties"))
.addSource(new ClassPathConfigSource("/dev.properties"))
.addSource(new MapConfigSource(configs))
.build();

// Load the configurations, this will throw exceptions if there are any errors.
gestalt.loadConfigs();

GestaltBuilder builderNoCache = new GestaltBuilder();
gestaltNoCache = builderNoCache
.addSource(ClassPathConfigSourceBuilder.builder().setResource("/default.properties").build())
.addSource(ClassPathConfigSourceBuilder.builder().setResource("/dev.properties").build())
.addSource(MapConfigSourceBuilder.builder().setCustomConfig(configs).build())
.addSource(new ClassPathConfigSource("/default.properties"))
.addSource(new ClassPathConfigSource("/dev.properties"))
.addSource(new MapConfigSource(configs))
.useCacheDecorator(false)
.build();

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ checkStyle = "10.10.0"
jmh = "1.37"
gradleJmh = "0.7.2"
# @pin gestalt for integration tests.
gestalt = "0.24.6"
gestalt = "0.25.0"
# Gradle utility
gradleVersions = "0.51.0"
gitVersions = "3.0.0"
Expand Down

0 comments on commit e480d7d

Please sign in to comment.