diff options
| author | Hongyu <39747921+HongyuHe@users.noreply.github.com> | 2021-03-26 15:47:14 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-26 15:47:14 +0100 |
| commit | 57ebc8a1c6779d7e7276754838e83f1c026cceb9 (patch) | |
| tree | 644ff72bba7e31dab19f4258f4feaeaa4bcc275a /simulator/opendc-simulator/opendc-simulator-compute/src/test/kotlin | |
| parent | 074dee1cbca7b3a024d45a3b9dd7d8b51acdd4ee (diff) | |
simulator: Extract hardware power values to a separate file (#105)
This change enables the use of the interpolation model testing on the results of the SPEC benchmark.
Diffstat (limited to 'simulator/opendc-simulator/opendc-simulator-compute/src/test/kotlin')
| -rw-r--r-- | simulator/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/MachinePowerModelTest.kt | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/MachinePowerModelTest.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/MachinePowerModelTest.kt index 9fdd0363..13bb3668 100644 --- a/simulator/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/MachinePowerModelTest.kt +++ b/simulator/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/MachinePowerModelTest.kt @@ -1,9 +1,10 @@ package org.opendc.simulator.compute.power -import io.mockk.* import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.flow.* +import org.junit.jupiter.api.Assertions.assertAll import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource @@ -36,6 +37,27 @@ internal class MachinePowerModelTest { assertEquals(0.0, computedPowerConsumption) } + @Test + fun `compute power draw by the SPEC benchmark model`() { + val powerModel = InterpolationPowerModel("IBMx3550M3_XeonX5675") + + assertAll( + { assertThrows<IllegalArgumentException> { powerModel.computeCpuPower(-1.3) } }, + { assertThrows<IllegalArgumentException> { powerModel.computeCpuPower(1.3) } }, + ) + + assertAll( + { assertEquals(58.4, powerModel.computeCpuPower(0.0)) }, + { assertEquals(58.4 + (98 - 58.4) / 5, powerModel.computeCpuPower(0.02)) }, + { assertEquals(98.0, powerModel.computeCpuPower(0.1)) }, + { assertEquals(140.0, powerModel.computeCpuPower(0.5)) }, + { assertEquals(189.0, powerModel.computeCpuPower(0.8)) }, + { assertEquals(189.0 + 0.7 * 10 * (205 - 189) / 10, powerModel.computeCpuPower(0.87)) }, + { assertEquals(205.0, powerModel.computeCpuPower(0.9)) }, + { assertEquals(222.0, powerModel.computeCpuPower(1.0)) }, + ) + } + @Suppress("unused") private companion object { @JvmStatic |
