summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-flow/src/jmh/kotlin
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-09-01 12:02:06 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2022-10-21 22:13:03 +0200
commite4f4e1c4ebd02278dc1c24ee481357989af6abe5 (patch)
tree5a47c06fe292adab47d56e1bc53ec1bf7a1a6c05 /opendc-simulator/opendc-simulator-flow/src/jmh/kotlin
parentad88144923d76dfc421f0b22a0b4e670b3f6366e (diff)
feat(sim/flow): Support flow transformations
This change adds a new component, FlowTransform, which is able to transform the flow from one component to another, based on some inversible transformation. Such as component is useful when converting between different units of flow between different components.
Diffstat (limited to 'opendc-simulator/opendc-simulator-flow/src/jmh/kotlin')
-rw-r--r--opendc-simulator/opendc-simulator-flow/src/jmh/kotlin/org/opendc/simulator/flow2/FlowBenchmarks.kt16
1 files changed, 16 insertions, 0 deletions
diff --git a/opendc-simulator/opendc-simulator-flow/src/jmh/kotlin/org/opendc/simulator/flow2/FlowBenchmarks.kt b/opendc-simulator/opendc-simulator-flow/src/jmh/kotlin/org/opendc/simulator/flow2/FlowBenchmarks.kt
index 1b0e2e9e..fb112082 100644
--- a/opendc-simulator/opendc-simulator-flow/src/jmh/kotlin/org/opendc/simulator/flow2/FlowBenchmarks.kt
+++ b/opendc-simulator/opendc-simulator-flow/src/jmh/kotlin/org/opendc/simulator/flow2/FlowBenchmarks.kt
@@ -26,6 +26,8 @@ import kotlinx.coroutines.launch
import org.opendc.simulator.flow2.mux.MaxMinFlowMultiplexer
import org.opendc.simulator.flow2.sink.SimpleFlowSink
import org.opendc.simulator.flow2.source.TraceFlowSource
+import org.opendc.simulator.flow2.util.FlowTransformer
+import org.opendc.simulator.flow2.util.FlowTransforms
import org.opendc.simulator.kotlin.runSimulation
import org.openjdk.jmh.annotations.Benchmark
import org.openjdk.jmh.annotations.Fork
@@ -67,6 +69,20 @@ class FlowBenchmarks {
}
@Benchmark
+ fun benchmarkForward() {
+ return runSimulation {
+ val engine = FlowEngine.create(coroutineContext, clock)
+ val graph = engine.newGraph()
+ val sink = SimpleFlowSink(graph, 4200.0f)
+ val source = TraceFlowSource(graph, trace)
+ val forwarder = FlowTransformer(graph, FlowTransforms.noop())
+
+ graph.connect(source.output, forwarder.input)
+ graph.connect(forwarder.output, sink.input)
+ }
+ }
+
+ @Benchmark
fun benchmarkMuxMaxMinSingleSource() {
return runSimulation {
val engine = FlowEngine.create(coroutineContext, clock)