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

Commit

Permalink
fix: a bug on how values are aggregated has been fixed inside all lib…
Browse files Browse the repository at this point in the history
…pfm sensors
  • Loading branch information
mcolmant committed Jun 2, 2017
1 parent c23dd9d commit c061ab9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Expand Up @@ -123,9 +123,9 @@ class LibpfmCoreProcessSensor(eventBus: MessageBus, muid: UUID, target: Target,
(core, event, Await.result(actor.?(msg.tick)(timeout), timeout.duration).asInstanceOf[HWCounter])
}

publishPCReport(muid, target, allValues.groupBy(tuple3 => (tuple3._1, tuple3._2)).map {
case ((core, event), values) => Map[Int, Map[String, Seq[HWCounter]]](core -> Map(event -> values.map(_._3).toSeq))
}.foldLeft(Map[Int, Map[String, Seq[HWCounter]]]())((acc, elt) => acc ++ elt), msg.tick)(eventBus)
publishPCReport(muid, target, allValues.foldLeft(Map[Int, Map[String, Seq[HWCounter]]]()) {
case (acc, elt) => acc + (elt._1 -> (acc.getOrElse(elt._1, Map()) + (elt._2 -> (acc.getOrElse(elt._1, Map()).getOrElse(elt._2, Seq()) :+ elt._3))))
}, msg.tick)(eventBus)

context.become(sense(newIdentifiers) orElse sensorDefault)
}
Expand Down
Expand Up @@ -87,8 +87,8 @@ class LibpfmCoreSensor(eventBus: MessageBus, muid: UUID, target: Target, libpfmH
(core, event, Await.result(actor.?(msg.tick)(timeout), timeout.duration).asInstanceOf[HWCounter])
}

publishPCReport(muid, target, allValues.groupBy(tuple3 => (tuple3._1, tuple3._2)).map {
case ((core, event), values) => Map[Int, Map[String, Seq[HWCounter]]](core -> Map(event -> values.map(_._3).toSeq))
}.foldLeft(Map[Int, Map[String, Seq[HWCounter]]]())((acc, elt) => acc ++ elt), msg.tick)(eventBus)
publishPCReport(muid, target, allValues.foldLeft(Map[Int, Map[String, Seq[HWCounter]]]()) {
case (acc, elt) => acc + (elt._1 -> (acc.getOrElse(elt._1, Map()) + (elt._2 -> (acc.getOrElse(elt._1, Map()).getOrElse(elt._2, Seq()) :+ elt._3))))
}, msg.tick)(eventBus)
}
}
Expand Up @@ -121,6 +121,7 @@ class LibpfmCoreProcessSensorSuite extends UnitTest with MockFactory {
values.size should equal(topology.size)

for (value <- values) {
value._2.size should equal(events.size)
for ((event, counters) <- value._2) {
counters.map(_.value).sum should equal(results((value._1, event)))
}
Expand Down
Expand Up @@ -105,6 +105,7 @@ class LibpfmCoreSensorSuite extends UnitTest with MockFactory {
values.size should equal(topology.size)

for (value <- values) {
value._2.keys.size should equal(events.size)
for ((event, counters) <- value._2) {
counters.map(_.value).sum should equal(results((value._1, event)))
}
Expand Down

0 comments on commit c061ab9

Please sign in to comment.