summaryrefslogtreecommitdiff
path: root/opendc-faas/opendc-faas-simulator
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-11-04 17:14:46 +0100
committerFabian Mastenbroek <mail.fabianm@gmail.com>2022-11-04 17:21:58 +0100
commit7143584da87e248277ab95a4848a57eccd62db69 (patch)
treef889f310de1ec33ab59d3fe04e204f9cc7c11b4d /opendc-faas/opendc-faas-simulator
parentacb45a1dea61dd844fba839cc31c79a7aca4bbe4 (diff)
refactor: Use RandomGenerator as randomness source
This change updates the modules of OpenDC to always accept the `RandomGenerator` interface as source of randomness. This interface is implemented by the slower `java.util.Random` class, but also by the faster `java.util.SplittableRandom` class
Diffstat (limited to 'opendc-faas/opendc-faas-simulator')
-rw-r--r--opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/delay/StochasticDelayInjector.kt4
1 files changed, 2 insertions, 2 deletions
diff --git a/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/delay/StochasticDelayInjector.kt b/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/delay/StochasticDelayInjector.kt
index d3b31bb9..de7b4aa5 100644
--- a/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/delay/StochasticDelayInjector.kt
+++ b/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/delay/StochasticDelayInjector.kt
@@ -23,13 +23,13 @@
package org.opendc.faas.simulator.delay
import org.opendc.faas.service.deployer.FunctionInstance
-import java.util.Random
+import java.util.random.RandomGenerator
import kotlin.math.abs
/*
* Interface for instance deployment delay estimation.
*/
-public class StochasticDelayInjector(private val model: ColdStartModel, private val random: Random) : DelayInjector {
+public class StochasticDelayInjector(private val model: ColdStartModel, private val random: RandomGenerator) : DelayInjector {
override fun getColdStartDelay(instance: FunctionInstance): Long {
val (mean, sd) = model.coldStartParam(instance.function.memorySize.toInt())
return abs(random.nextGaussian() * sd + mean).toLong()