Skip to content

Commit 7034d91

Browse files
committed
Statistics reporting: aggregate keys with common prefix
1 parent be65f09 commit 7034d91

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

compiler/src/dotty/tools/dotc/util/Stats.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ import collection.mutable
7575
}
7676
}
7777

78+
final val GroupChar = '/'
79+
80+
/** Aggregate all counts of all keys with a common prefix, followed by `:` */
81+
private def aggregate(): Unit = {
82+
val groups = hits.keys
83+
.filter(_.contains(GroupChar))
84+
.groupBy(_.takeWhile(_ != GroupChar))
85+
for ((prefix, names) <- groups; name <- names)
86+
hits(s"Total $prefix") += hits(name)
87+
}
88+
7889
def maybeMonitored[T](op: => T)(implicit ctx: Context): T = {
7990
if (ctx.settings.YdetailedStats.value) {
8091
val hb = new HeartBeat()
@@ -83,6 +94,7 @@ import collection.mutable
8394
try op
8495
finally {
8596
hb.continue = false
97+
aggregate()
8698
println()
8799
println(hits.toList.sortBy(_._2).map{ case (x, y) => s"$x -> $y" } mkString "\n")
88100
println(s"uniqueInfo (size, accesses, collisions): ${ctx.base.uniquesSizes}")

0 commit comments

Comments
 (0)