summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-compute
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-10-04 19:26:29 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-10-05 15:03:02 +0200
commit557797c63c19e80c908eccc96472f215eab0c2f3 (patch)
tree711eec495cf1bc319ff7077c0ffea9d2ac3e62a6 /opendc-simulator/opendc-simulator-compute
parent5c4f9d936d7c08e8ad2705ed3dde5ea8dcd2ee64 (diff)
perf(experiments): Add benchmark for Capelin experiment
Diffstat (limited to 'opendc-simulator/opendc-simulator-compute')
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt50
1 files changed, 21 insertions, 29 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 d654d58a..b8e0227a 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
@@ -22,6 +22,7 @@
package org.opendc.simulator.compute
+import javafx.application.Application.launch
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
@@ -34,7 +35,6 @@ import org.opendc.simulator.compute.model.ProcessingUnit
import org.opendc.simulator.compute.power.ConstantPowerModel
import org.opendc.simulator.compute.power.SimplePowerDriver
import org.opendc.simulator.compute.workload.SimTraceWorkload
-import org.opendc.simulator.core.SimulationCoroutineScope
import org.opendc.simulator.core.runBlockingSimulation
import org.opendc.simulator.flow.FlowEngine
import org.openjdk.jmh.annotations.*
@@ -47,48 +47,38 @@ import java.util.concurrent.TimeUnit
@Measurement(iterations = 5, time = 3, timeUnit = TimeUnit.SECONDS)
@OptIn(ExperimentalCoroutinesApi::class)
class SimMachineBenchmarks {
- private lateinit var scope: SimulationCoroutineScope
- private lateinit var engine: FlowEngine
private lateinit var machineModel: MachineModel
+ private lateinit var trace: Sequence<SimTraceWorkload.Fragment>
@Setup
fun setUp() {
- scope = SimulationCoroutineScope()
- engine = FlowEngine(scope.coroutineContext, scope.clock)
-
val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 2)
machineModel = MachineModel(
cpus = List(cpuNode.coreCount) { ProcessingUnit(cpuNode, it, 1000.0) },
memory = List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) }
)
- }
- @State(Scope.Thread)
- class Workload {
- lateinit var trace: Sequence<SimTraceWorkload.Fragment>
-
- @Setup
- fun setUp() {
- val random = ThreadLocalRandom.current()
- val entries = List(10000) { SimTraceWorkload.Fragment(it * 1000L, 1000, random.nextDouble(0.0, 4500.0), 1) }
- trace = entries.asSequence()
- }
+ val random = ThreadLocalRandom.current()
+ val entries = List(10000) { SimTraceWorkload.Fragment(it * 1000L, 1000, random.nextDouble(0.0, 4500.0), 1) }
+ trace = entries.asSequence()
}
@Benchmark
- fun benchmarkBareMetal(state: Workload) {
- return scope.runBlockingSimulation {
+ fun benchmarkBareMetal() {
+ return runBlockingSimulation {
+ val engine = FlowEngine(coroutineContext, clock)
val machine = SimBareMetalMachine(
engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0))
)
- return@runBlockingSimulation machine.run(SimTraceWorkload(state.trace))
+ return@runBlockingSimulation machine.run(SimTraceWorkload(trace))
}
}
@Benchmark
- fun benchmarkSpaceSharedHypervisor(state: Workload) {
- return scope.runBlockingSimulation {
+ fun benchmarkSpaceSharedHypervisor() {
+ return runBlockingSimulation {
+ val engine = FlowEngine(coroutineContext, clock)
val machine = SimBareMetalMachine(
engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0))
)
@@ -99,7 +89,7 @@ class SimMachineBenchmarks {
val vm = hypervisor.createMachine(machineModel)
try {
- return@runBlockingSimulation vm.run(SimTraceWorkload(state.trace))
+ return@runBlockingSimulation vm.run(SimTraceWorkload(trace))
} finally {
vm.close()
machine.close()
@@ -108,8 +98,9 @@ class SimMachineBenchmarks {
}
@Benchmark
- fun benchmarkFairShareHypervisorSingle(state: Workload) {
- return scope.runBlockingSimulation {
+ fun benchmarkFairShareHypervisorSingle() {
+ return runBlockingSimulation {
+ val engine = FlowEngine(coroutineContext, clock)
val machine = SimBareMetalMachine(
engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0))
)
@@ -120,7 +111,7 @@ class SimMachineBenchmarks {
val vm = hypervisor.createMachine(machineModel)
try {
- return@runBlockingSimulation vm.run(SimTraceWorkload(state.trace))
+ return@runBlockingSimulation vm.run(SimTraceWorkload(trace))
} finally {
vm.close()
machine.close()
@@ -129,8 +120,9 @@ class SimMachineBenchmarks {
}
@Benchmark
- fun benchmarkFairShareHypervisorDouble(state: Workload) {
- return scope.runBlockingSimulation {
+ fun benchmarkFairShareHypervisorDouble() {
+ return runBlockingSimulation {
+ val engine = FlowEngine(coroutineContext, clock)
val machine = SimBareMetalMachine(
engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0))
)
@@ -144,7 +136,7 @@ class SimMachineBenchmarks {
launch {
try {
- vm.run(SimTraceWorkload(state.trace))
+ vm.run(SimTraceWorkload(trace))
} finally {
machine.close()
}