diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-08-22 13:21:53 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-08-22 13:31:42 +0200 |
| commit | 766b41566f4cf8297202147d789e135a76041ed4 (patch) | |
| tree | 05bc283c64ecc8d2c7dad07c4d28612004b43ca2 /opendc-simulator | |
| parent | f84dc9f8b8b4eaa7621f9ee4fc83ef38a85c431b (diff) | |
perf(simulator): Prevent counter update without work
This change implements a performance improvement by preventing updates
on the resource counters in case no work was performed in the last
cycle.
Diffstat (limited to 'opendc-simulator')
| -rw-r--r-- | opendc-simulator/opendc-simulator-resources/src/main/kotlin/org/opendc/simulator/resources/SimAbstractResourceProvider.kt | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/opendc-simulator/opendc-simulator-resources/src/main/kotlin/org/opendc/simulator/resources/SimAbstractResourceProvider.kt b/opendc-simulator/opendc-simulator-resources/src/main/kotlin/org/opendc/simulator/resources/SimAbstractResourceProvider.kt index c1b1450e..2ceb1e3c 100644 --- a/opendc-simulator/opendc-simulator-resources/src/main/kotlin/org/opendc/simulator/resources/SimAbstractResourceProvider.kt +++ b/opendc-simulator/opendc-simulator-resources/src/main/kotlin/org/opendc/simulator/resources/SimAbstractResourceProvider.kt @@ -88,6 +88,10 @@ public abstract class SimAbstractResourceProvider( * Update the counters of the resource provider. */ protected fun updateCounters(ctx: SimResourceContext, work: Double) { + if (work <= 0.0) { + return + } + val counters = _counters val remainingWork = ctx.remainingWork counters.demand += work |
