Skip to content

Commit

Permalink
Merge pull request scala#10795 from szeiger/wip/collect-statistics-2.13
Browse files Browse the repository at this point in the history
Collect statistics without printing them
  • Loading branch information
lrytz committed Jun 26, 2024
2 parents 9e80aa3 + 61ca27a commit bea510c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/nsc/Global.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
checkPhaseSettings(including = false, exclusions.map(_.value): _*)

// Report the overhead of statistics measurements per every run
if (settings.areStatisticsEnabled)
if (settings.areStatisticsEnabled && settings.Ystatistics.value.nonEmpty)
statistics.reportStatisticsOverhead(reporter)

phase = first //parserPhase
Expand Down Expand Up @@ -1628,7 +1628,7 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
}
symSource.keys foreach (x => resetPackageClass(x.owner))

if (timePhases) {
if (timePhases && settings.Ystatistics.value.nonEmpty) {
statistics.stopTimer(totalCompileTime, startTotal)
informTime("total", totalCompileTime.nanos)
inform("*** Cumulative timers for phases")
Expand Down
6 changes: 4 additions & 2 deletions src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -607,12 +607,14 @@ trait ScalaSettings extends StandardScalaSettings with Warnings { _: MutableSett
.withAbbreviation("-Yshow-symkinds")
val Yshowsymowners = BooleanSetting ("-Vshow-symowners", "Print owner identifiers next to symbol names.")
.withAbbreviation("-Yshow-symowners")
val Ystatistics = PhasesSetting("-Vstatistics", "Print compiler statistics for specific phases", "parser,typer,patmat,erasure,cleanup,jvm")
.withPostSetHook(s => YstatisticsEnabled.value = s.value.nonEmpty)
val Ystatistics = PhasesSetting("-Vstatistics", "Print compiler statistics for specific phases (implies `-Ycollect-statistics`)", "parser,typer,patmat,erasure,cleanup,jvm")
.withPostSetHook(s => if (s.value.nonEmpty) YstatisticsEnabled.value = true)
.withAbbreviation("-Ystatistics")
val YstatisticsEnabled = BooleanSetting("-Ystatistics-enabled", "Internal setting, indicating that statistics are enabled for some phase.").internalOnly().withPostSetHook(s => if (s.value) StatisticsStatics.enableColdStatsAndDeoptimize())
val YhotStatisticsEnabled = BooleanSetting("-Vhot-statistics", s"Enable `${Ystatistics.name}` to also print hot statistics.")
.withAbbreviation("-Yhot-statistics").withPostSetHook(s => if (s.value && YstatisticsEnabled.value) StatisticsStatics.enableHotStatsAndDeoptimize())
val YcollectStatistics = BooleanSetting("-Ycollect-statistics", "Collect cold statistics (quietly, unless `-Vstatistics` is set)")
.withPostSetHook(s => if (s.value) YstatisticsEnabled.value = true)
val Yshowsyms = BooleanSetting("-Vsymbols", "Print the AST symbol hierarchy after each phase.") withAbbreviation "-Yshow-syms"
val Ytyperdebug = BooleanSetting("-Vtyper", "Trace type assignments.") withAbbreviation "-Ytyper-debug"
val Vimplicits = BooleanSetting("-Vimplicits", "Print dependent missing implicits.").withAbbreviation("-Xlog-implicits")
Expand Down

0 comments on commit bea510c

Please sign in to comment.