summaryrefslogtreecommitdiff
path: root/opendc-simulator
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-simulator')
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/BenchmarkHelpers.kt43
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt27
2 files changed, 17 insertions, 53 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/BenchmarkHelpers.kt b/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/BenchmarkHelpers.kt
deleted file mode 100644
index 43bbfd0b..00000000
--- a/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/BenchmarkHelpers.kt
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2021 AtLarge Research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package org.opendc.simulator.compute
-
-import org.opendc.simulator.compute.workload.SimTraceWorkload
-
-/**
- * Helper function to create simple consumer workload.
- */
-fun createSimpleConsumer(): SimTraceWorkload {
- return SimTraceWorkload(
- sequenceOf(
- SimTraceWorkload.Fragment(1000, 28.0, 1),
- SimTraceWorkload.Fragment(1000, 3500.0, 1),
- SimTraceWorkload.Fragment(1000, 0.0, 1),
- SimTraceWorkload.Fragment(1000, 183.0, 1),
- SimTraceWorkload.Fragment(1000, 400.0, 1),
- SimTraceWorkload.Fragment(1000, 100.0, 1),
- SimTraceWorkload.Fragment(1000, 3000.0, 1),
- SimTraceWorkload.Fragment(1000, 4500.0, 1),
- ),
- )
-}
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 7b97a665..bae31921 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
@@ -31,12 +31,11 @@ import org.opendc.simulator.compute.model.MemoryUnit
import org.opendc.simulator.compute.model.ProcessingNode
import org.opendc.simulator.compute.model.ProcessingUnit
import org.opendc.simulator.compute.power.ConstantPowerModel
-import org.opendc.simulator.compute.workload.SimWorkload
+import org.opendc.simulator.compute.workload.SimTraceWorkload
import org.opendc.simulator.core.SimulationCoroutineScope
import org.opendc.simulator.core.runBlockingSimulation
import org.opendc.utils.TimerScheduler
import org.openjdk.jmh.annotations.*
-import java.time.Clock
import java.util.concurrent.TimeUnit
@State(Scope.Thread)
@@ -46,14 +45,13 @@ import java.util.concurrent.TimeUnit
@OptIn(ExperimentalCoroutinesApi::class)
class SimMachineBenchmarks {
private lateinit var scope: SimulationCoroutineScope
- private lateinit var clock: Clock
private lateinit var scheduler: TimerScheduler<Any>
private lateinit var machineModel: SimMachineModel
@Setup
fun setUp() {
scope = SimulationCoroutineScope()
- scheduler = TimerScheduler(scope.coroutineContext, clock)
+ scheduler = TimerScheduler(scope.coroutineContext, scope.clock)
val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 2)
@@ -65,11 +63,20 @@ class SimMachineBenchmarks {
@State(Scope.Thread)
class Workload {
- lateinit var workloads: Array<SimWorkload>
+ lateinit var trace: Sequence<SimTraceWorkload.Fragment>
@Setup
fun setUp() {
- workloads = Array(2) { createSimpleConsumer() }
+ trace = sequenceOf(
+ SimTraceWorkload.Fragment(1000, 28.0, 1),
+ SimTraceWorkload.Fragment(1000, 3500.0, 1),
+ SimTraceWorkload.Fragment(1000, 0.0, 1),
+ SimTraceWorkload.Fragment(1000, 183.0, 1),
+ SimTraceWorkload.Fragment(1000, 400.0, 1),
+ SimTraceWorkload.Fragment(1000, 100.0, 1),
+ SimTraceWorkload.Fragment(1000, 3000.0, 1),
+ SimTraceWorkload.Fragment(1000, 4500.0, 1),
+ )
}
}
@@ -80,7 +87,7 @@ class SimMachineBenchmarks {
coroutineContext, clock, machineModel, PerformanceScalingGovernor(),
SimpleScalingDriver(ConstantPowerModel(0.0))
)
- return@runBlockingSimulation machine.run(state.workloads[0])
+ return@runBlockingSimulation machine.run(SimTraceWorkload(state.trace))
}
}
@@ -98,7 +105,7 @@ class SimMachineBenchmarks {
val vm = hypervisor.createMachine(machineModel)
try {
- return@runBlockingSimulation vm.run(state.workloads[0])
+ return@runBlockingSimulation vm.run(SimTraceWorkload(state.trace))
} finally {
vm.close()
machine.close()
@@ -120,7 +127,7 @@ class SimMachineBenchmarks {
val vm = hypervisor.createMachine(machineModel)
try {
- return@runBlockingSimulation vm.run(state.workloads[0])
+ return@runBlockingSimulation vm.run(SimTraceWorkload(state.trace))
} finally {
vm.close()
machine.close()
@@ -145,7 +152,7 @@ class SimMachineBenchmarks {
launch {
try {
- vm.run(state.workloads[i])
+ vm.run(SimTraceWorkload(state.trace))
} finally {
machine.close()
}