summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-compute/src/jmh
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-10-06 13:12:18 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-10-08 17:11:52 +0200
commit94fa3d33d4ef77aca5e70cc7f91ae9dca71d25e7 (patch)
tree42ec6c1cc5fe027d6e0568986b9a81c03ab90838 /opendc-simulator/opendc-simulator-compute/src/jmh
parent3098eeb116a80ce12e6575e454d0448867478792 (diff)
perf(simulator): Optimize SimTraceWorkload
This change improves the performance of the SimTraceWorkload class by changing the way trace fragments are read and processed by the CPU consumers.
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.kt13
1 files changed, 9 insertions, 4 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 b8e0227a..cb52d24f 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,7 +22,6 @@
package org.opendc.simulator.compute
-import javafx.application.Application.launch
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
@@ -34,6 +33,7 @@ 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.power.SimplePowerDriver
+import org.opendc.simulator.compute.workload.SimTrace
import org.opendc.simulator.compute.workload.SimTraceWorkload
import org.opendc.simulator.core.runBlockingSimulation
import org.opendc.simulator.flow.FlowEngine
@@ -48,7 +48,7 @@ import java.util.concurrent.TimeUnit
@OptIn(ExperimentalCoroutinesApi::class)
class SimMachineBenchmarks {
private lateinit var machineModel: MachineModel
- private lateinit var trace: Sequence<SimTraceWorkload.Fragment>
+ private lateinit var trace: SimTrace
@Setup
fun setUp() {
@@ -60,8 +60,13 @@ class SimMachineBenchmarks {
)
val random = ThreadLocalRandom.current()
- val entries = List(10000) { SimTraceWorkload.Fragment(it * 1000L, 1000, random.nextDouble(0.0, 4500.0), 1) }
- trace = entries.asSequence()
+ val builder = SimTrace.builder()
+ repeat(10000) {
+ val timestamp = it.toLong()
+ val deadline = timestamp + 1000
+ builder.add(timestamp, deadline, random.nextDouble(0.0, 4500.0), 1)
+ }
+ trace = builder.build()
}
@Benchmark