Skip to content
This repository was archived by the owner on Mar 11, 2019. It is now read-only.

Commit c67d70e

Browse files
committed
chore: move powerspy-core to scala 2.12
chore: fix the CLI help (remove non-existing aggregator) fix: there was a problem with the conversion when the powers were aggregated (add also a test to cover this case)
1 parent e488592 commit c67d70e

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

powerapi-cli/src/main/scala/org/powerapi/app/PowerAPI.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ object PowerAPI extends App {
9595
| monitor (1, *)
9696
| --frequency $MILLISECONDS
9797
| --self (0, 1) --pids [pid, ...] (0, *) --apps [app, ...] (0, *) --containers [id, ...] (0, *) | all (0, 1)
98-
| --agg max|min|geomean|logsum|mean|median|stdev|sum|variance
98+
| --agg max|min|mean|median|sum
9999
| --console (0, 1) --file $FILEPATH (0, *) --chart (0, 1) --influx $HOST $PORT $USER $PWD $DB $MEASUREMENT (0, *)
100100
| duration [s]
101101
|

powerapi-core/build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ resolvers ++= Seq(
1414
libraryDependencies ++= Seq(
1515
"com.typesafe.akka" %% "akka-actor" % "2.4.14",
1616
"com.typesafe" % "config" % "1.3.1",
17-
"fr.inria.powerspy" % "powerspy-core_2.11" % "1.2",
17+
"fr.inria.powerspy" %% "powerspy-core" % "1.2",
1818
"com.nativelibs4java" % "bridj" % "0.7.0",
1919
"org.jfree" % "jfreechart" % "1.0.19",
2020
"org.clapper" %% "grizzled-scala" % "4.0.0",

powerapi-core/src/main/scala/org/powerapi/core/power/package.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ package object power {
3232
final val KILOWATTS = org.powerapi.core.power.PowerConverter.KILOWATTS
3333
final val MEGAWATTS = org.powerapi.core.power.PowerConverter.MEGAWATTS
3434

35-
def MAX(s: Seq[Power]): Power = s.map(_.value).max.mW
35+
def MAX(s: Seq[Power]): Power = s.map(_.toMilliWatts).max.mW
3636

37-
def MIN(s: Seq[Power]): Power = s.map(_.value).min.mW
37+
def MIN(s: Seq[Power]): Power = s.map(_.toMilliWatts).min.mW
3838

39-
def SUM(s : Seq[Power]): Power = s.map(_.value).sum.mW
39+
def SUM(s : Seq[Power]): Power = s.map(_.toMilliWatts).sum.mW
4040

41-
def MEAN(s: Seq[Power]): Power = mean(s.map(_.value): _*).mW
41+
def MEAN(s: Seq[Power]): Power = mean(s.map(_.toMilliWatts): _*).mW
4242

43-
def MEDIAN(s: Seq[Power]): Power = median(s.map(_.value): _*).mW
43+
def MEDIAN(s: Seq[Power]): Power = median(s.map(_.toMilliWatts): _*).mW
4444

4545
implicit final class DoublePower(private val value: Double) extends AnyVal {
4646
def mW: Power = Power(value, MILLIWATTS)

powerapi-core/src/test/scala/org/powerapi/core/power/PowerSuite.scala

+8-6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,8 @@ class PowerSuite extends UnitTest {
3838

3939
"A Power" should "handle a various kind of operations" in {
4040
val p1 = Power(1.0, "W")
41-
p1 should (
42-
equal(1.W) and
43-
equal(1000L.mW) and
44-
equal(0.001.kW) and
45-
equal(Power(1.0, "nW"))
46-
)
41+
p1 should (equal(1.W) and equal(1000L.mW) and equal(0.001.kW) and equal(Power(1.0, "nW")))
42+
4743
p1.value should (
4844
equal(0.000001.MW.toWatts) and
4945
equal(1000L.mW.toUnit(WATTS))
@@ -91,6 +87,12 @@ class PowerSuite extends UnitTest {
9187
0.5.W / 2 should equal(250.mW)
9288
1000L.MW / 100 should equal(10000.kW)
9389

90+
MAX(Seq(10.W, 10.mW)) should equal(10.W)
91+
MIN(Seq(10.W, 10.mW)) should equal(10.mW)
92+
SUM(Seq(10.W, 10.mW)) should equal(10010.mW)
93+
MEAN(Seq(10.W, 10.W)) should equal(10.W)
94+
MEDIAN(Seq(10.W, 10.mW, 12.mW)) should equal(12.mW)
95+
9496
intercept[java.lang.IllegalArgumentException] {
9597
1.W * Double.NaN
9698
}

0 commit comments

Comments
 (0)