summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-compute/src
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-09-30 12:14:42 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-10-03 17:17:36 +0200
commit0ffd93933228e87a205c9839d1bf04cd0e178e8c (patch)
tree74994415fc81c149d6e8c46e6e7510b534aa9cae /opendc-simulator/opendc-simulator-compute/src
parent83e6c19681a5cae4b80773f95a66b6753b0bcd7e (diff)
test(simulator): Use longer traces for benchmarks
This change updates the JMH benchmarks to use longer traces in order to measure the overhead of running the flow simulation as opposed to setting up the benchmark.
Diffstat (limited to 'opendc-simulator/opendc-simulator-compute/src')
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt16
1 files changed, 5 insertions, 11 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt b/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt
index 30797089..88ad7286 100644
--- a/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt
@@ -38,6 +38,7 @@ import org.opendc.simulator.core.SimulationCoroutineScope
import org.opendc.simulator.core.runBlockingSimulation
import org.opendc.simulator.resources.SimResourceInterpreter
import org.openjdk.jmh.annotations.*
+import java.util.concurrent.ThreadLocalRandom
import java.util.concurrent.TimeUnit
@State(Scope.Thread)
@@ -63,22 +64,15 @@ class SimMachineBenchmarks {
)
}
- @State(Scope.Benchmark)
+ @State(Scope.Thread)
class Workload {
lateinit var trace: Sequence<SimTraceWorkload.Fragment>
@Setup
fun setUp() {
- trace = sequenceOf(
- SimTraceWorkload.Fragment(0, 1000, 28.0, 1),
- SimTraceWorkload.Fragment(1000, 1000, 3500.0, 1),
- SimTraceWorkload.Fragment(2000, 1000, 0.0, 1),
- SimTraceWorkload.Fragment(3000, 1000, 183.0, 1),
- SimTraceWorkload.Fragment(4000, 1000, 400.0, 1),
- SimTraceWorkload.Fragment(5000, 1000, 100.0, 1),
- SimTraceWorkload.Fragment(6000, 1000, 3000.0, 1),
- SimTraceWorkload.Fragment(7000, 1000, 4500.0, 1),
- )
+ val random = ThreadLocalRandom.current()
+ val entries = List(10000) { SimTraceWorkload.Fragment(it * 1000L, 1000, random.nextDouble(0.0, 4500.0), 1) }
+ trace = entries.asSequence()
}
}