Fix runtime-instrument-common benchmark (#11619)

This commit is contained in:
Dmitry Bushev 2024-11-21 21:42:43 +03:00 committed by GitHub
parent 0e31169782
commit 8930387693
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 78 deletions

View File

@ -3286,21 +3286,15 @@ lazy val `runtime-suggestions` =
lazy val `runtime-instrument-common` =
(project in file("engine/runtime-instrument-common"))
.enablePlugins(JPMSPlugin)
.configs(Benchmark)
.settings(
frgaalJavaCompilerSetting,
scalaModuleDependencySetting,
mixedJavaScalaProjectSetting,
inConfig(Compile)(truffleRunOptionsSettings),
inConfig(Benchmark)(Defaults.testSettings),
instrumentationSettings,
Test / javaOptions ++= Seq(
"-Dpolyglotimpl.DisableClassPathIsolation=true"
),
bench := (Benchmark / test).tag(Exclusive).value,
Benchmark / parallelExecution := false,
(Benchmark / javaOptions) :=
(LocalProject("std-benchmarks") / Compile / javaOptions).value,
Test / fork := true,
Test / envVars ++= distributionEnvironmentOverrides ++ Map(
"ENSO_TEST_DISABLE_IR_CACHE" -> "false"
@ -3338,7 +3332,7 @@ lazy val `runtime-instrument-common` =
)
)
.dependsOn(`refactoring-utils`)
.dependsOn(`runtime` % "compile->compile;runtime->runtime;bench->bench")
.dependsOn(`runtime` % "compile->compile;runtime->runtime")
lazy val `runtime-instrument-id-execution` =
(project in file("engine/runtime-instrument-id-execution"))

View File

@ -1,71 +0,0 @@
package org.enso.interpreter.bench.benchmarks;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.enso.interpreter.instrument.RuntimeCache;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.annotations.AuxCounters.Type;
@BenchmarkMode(Mode.AverageTime)
@Fork(1)
@Warmup(iterations = 5)
@Measurement(iterations = 5)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@State(Scope.Benchmark)
public class RuntimeCacheBenchmarks {
private final RuntimeCache cache = new RuntimeCache();
private int index = 0;
private UUID[] keys;
@Param({"1000000"})
public int items;
@State(Scope.Thread)
@AuxCounters(Type.EVENTS)
public static class CacheCounters {
private long hits = 0;
private long misses = 0;
public double hitRatio() {
return ((double) hits) / (hits + misses);
}
public void putHit() {
hits++;
}
public void putMiss() {
misses++;
}
}
public UUID nextKey() {
if (index == keys.length) {
index = 0;
}
UUID key = keys[index];
index++;
return key;
}
@Setup
public void setup() {
keys = new UUID[items];
for (int i = 0; i < items; i++) {
keys[i] = UUID.randomUUID();
cache.offer(keys[i], new Object());
}
}
@Benchmark
public void benchCacheGet(CacheCounters counters) {
Object result = cache.get(nextKey());
if (result == null) {
counters.putMiss();
} else {
counters.putHit();
}
}
}