mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 13:02:07 +03:00
Fix runtime-instrument-common benchmark (#11619)
This commit is contained in:
parent
0e31169782
commit
8930387693
@ -3286,21 +3286,15 @@ lazy val `runtime-suggestions` =
|
|||||||
lazy val `runtime-instrument-common` =
|
lazy val `runtime-instrument-common` =
|
||||||
(project in file("engine/runtime-instrument-common"))
|
(project in file("engine/runtime-instrument-common"))
|
||||||
.enablePlugins(JPMSPlugin)
|
.enablePlugins(JPMSPlugin)
|
||||||
.configs(Benchmark)
|
|
||||||
.settings(
|
.settings(
|
||||||
frgaalJavaCompilerSetting,
|
frgaalJavaCompilerSetting,
|
||||||
scalaModuleDependencySetting,
|
scalaModuleDependencySetting,
|
||||||
mixedJavaScalaProjectSetting,
|
mixedJavaScalaProjectSetting,
|
||||||
inConfig(Compile)(truffleRunOptionsSettings),
|
inConfig(Compile)(truffleRunOptionsSettings),
|
||||||
inConfig(Benchmark)(Defaults.testSettings),
|
|
||||||
instrumentationSettings,
|
instrumentationSettings,
|
||||||
Test / javaOptions ++= Seq(
|
Test / javaOptions ++= Seq(
|
||||||
"-Dpolyglotimpl.DisableClassPathIsolation=true"
|
"-Dpolyglotimpl.DisableClassPathIsolation=true"
|
||||||
),
|
),
|
||||||
bench := (Benchmark / test).tag(Exclusive).value,
|
|
||||||
Benchmark / parallelExecution := false,
|
|
||||||
(Benchmark / javaOptions) :=
|
|
||||||
(LocalProject("std-benchmarks") / Compile / javaOptions).value,
|
|
||||||
Test / fork := true,
|
Test / fork := true,
|
||||||
Test / envVars ++= distributionEnvironmentOverrides ++ Map(
|
Test / envVars ++= distributionEnvironmentOverrides ++ Map(
|
||||||
"ENSO_TEST_DISABLE_IR_CACHE" -> "false"
|
"ENSO_TEST_DISABLE_IR_CACHE" -> "false"
|
||||||
@ -3338,7 +3332,7 @@ lazy val `runtime-instrument-common` =
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
.dependsOn(`refactoring-utils`)
|
.dependsOn(`refactoring-utils`)
|
||||||
.dependsOn(`runtime` % "compile->compile;runtime->runtime;bench->bench")
|
.dependsOn(`runtime` % "compile->compile;runtime->runtime")
|
||||||
|
|
||||||
lazy val `runtime-instrument-id-execution` =
|
lazy val `runtime-instrument-id-execution` =
|
||||||
(project in file("engine/runtime-instrument-id-execution"))
|
(project in file("engine/runtime-instrument-id-execution"))
|
||||||
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user