diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 15aaf310dae1..9b48b7e33cc2 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -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 @@ -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") diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index d33bb6ac253b..a4b2febefd5d 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -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")