summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-compute/src/jmh
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-10-19 17:27:01 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-10-25 17:58:54 +0200
commit86c65e875b7dde8872dc81a37aa9dca72eee7782 (patch)
tree6249023f8f0d56392400c7ebb72238ee848f740a /opendc-simulator/opendc-simulator-compute/src/jmh
parentba310a3545c9631e1e4ff61a0a1759228ec5cf63 (diff)
refactor(simulator): Support running workloads without coroutines
This change updates the SimMachine interface to drop the coroutine requirement for running a workload on a machines. Users can now asynchronously start a workload and receive notifications via the workload callbacks. Users still have the possibility to suspend execution during workload execution by using the new `runWorkload` method, which is implemented on top of the new `startWorkload` primitive.
Diffstat (limited to 'opendc-simulator/opendc-simulator-compute/src/jmh')
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt32
1 files changed, 16 insertions, 16 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 cb52d24f..91e91f9d 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
@@ -76,7 +76,7 @@ class SimMachineBenchmarks {
val machine = SimBareMetalMachine(
engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0))
)
- return@runBlockingSimulation machine.run(SimTraceWorkload(trace))
+ return@runBlockingSimulation machine.runWorkload(SimTraceWorkload(trace))
}
}
@@ -89,15 +89,15 @@ class SimMachineBenchmarks {
)
val hypervisor = SimSpaceSharedHypervisor(engine, null, null)
- launch { machine.run(hypervisor) }
+ launch { machine.runWorkload(hypervisor) }
- val vm = hypervisor.createMachine(machineModel)
+ val vm = hypervisor.newMachine(machineModel)
try {
- return@runBlockingSimulation vm.run(SimTraceWorkload(trace))
+ return@runBlockingSimulation vm.runWorkload(SimTraceWorkload(trace))
} finally {
- vm.close()
- machine.close()
+ vm.cancel()
+ machine.cancel()
}
}
}
@@ -111,15 +111,15 @@ class SimMachineBenchmarks {
)
val hypervisor = SimFairShareHypervisor(engine, null, null, null)
- launch { machine.run(hypervisor) }
+ launch { machine.runWorkload(hypervisor) }
- val vm = hypervisor.createMachine(machineModel)
+ val vm = hypervisor.newMachine(machineModel)
try {
- return@runBlockingSimulation vm.run(SimTraceWorkload(trace))
+ return@runBlockingSimulation vm.runWorkload(SimTraceWorkload(trace))
} finally {
- vm.close()
- machine.close()
+ vm.cancel()
+ machine.cancel()
}
}
}
@@ -133,22 +133,22 @@ class SimMachineBenchmarks {
)
val hypervisor = SimFairShareHypervisor(engine, null, null, null)
- launch { machine.run(hypervisor) }
+ launch { machine.runWorkload(hypervisor) }
coroutineScope {
repeat(2) {
- val vm = hypervisor.createMachine(machineModel)
+ val vm = hypervisor.newMachine(machineModel)
launch {
try {
- vm.run(SimTraceWorkload(trace))
+ vm.runWorkload(SimTraceWorkload(trace))
} finally {
- machine.close()
+ machine.cancel()
}
}
}
}
- machine.close()
+ machine.cancel()
}
}
}