Skip to content

Commit

Permalink
Keep original time units in perFile macro expansions counting
Browse files Browse the repository at this point in the history
  • Loading branch information
danicheg committed Jul 6, 2024
1 parent 616b83b commit 860e1f4
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions plugin/src/main/scala/ch/epfl/scala/profilers/ProfilingImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ final class ProfilingImpl[G <: Global](
}

object MacroInfo {
final val Empty = MacroInfo(0, 0, 0.millis)
final val Empty = MacroInfo(0, 0, 0.nanos)
implicit val macroInfoOrdering: Ordering[MacroInfo] = Ordering.by(_.expansionTime)
def aggregate(infos: Iterator[MacroInfo]): MacroInfo = {
infos.foldLeft(MacroInfo.Empty)(_ + _)
Expand All @@ -79,25 +79,14 @@ final class ProfilingImpl[G <: Global](
import ProfilingMacroPlugin.macroInfos // , repeatedTrees}
val perCallSite = macroInfos.toMap
val perFile = groupPerFile(perCallSite)(MacroInfo.Empty, _ + _)
.map {
case (sf, mi) =>
sf -> mi.copy(expansionTime =
FiniteDuration(mi.expansionTime.toMillis, TimeUnit.MILLISECONDS)
)
}
val inTotal = MacroInfo.aggregate(perFile.valuesIterator)

/* val repeated = repeatedTrees.toMap.valuesIterator
.filter(_.count > 1)
.map(v => v.original -> v.count)
.toMap*/

val callSiteMicros = perCallSite.map {
case (k, v) =>
k -> v.copy(expansionTime = FiniteDuration(v.expansionTime.toMicros, TimeUnit.MICROSECONDS))
}

MacroProfiler(callSiteMicros, perFile, inTotal, Map.empty)
MacroProfiler(perCallSite, perFile, inTotal, Map.empty)
}

case class ImplicitInfo(count: Int) {
Expand Down

0 comments on commit 860e1f4

Please sign in to comment.