scalac-profiling

scalac-profiling

  • Docs
  • GitHub

›Usage

Usage

  • What is scalac-profiling?
  • Installation
  • Usage

Plugins

  • SBT Plugin
Edit

Installation

Pick the right version

Scala seriesSupported versionsscalac-profiling
2.12.x2.12.20, 2.12.19, 2.12.181.1.2
2.13.x2.13.16, 2.13.15, 2.13.141.1.2

Add the dependency

Add the scalac compiler plugin into your build:

addCompilerPlugin("ch.epfl.scala" %% "scalac-profiling" % "1.1.2" cross CrossVersion.full)

Also, it's required to enable compiler statistics — for Scala 2.13 the needed compiler flag is -Vstatistics, and for Scala 2.12 is -Ystatistics.

For example, for the SBT build tool, add the following settings to build.sbt:

+ inThisBuild(
+   List(
+     addCompilerPlugin("ch.epfl.scala" %% "scalac-profiling" % "1.1.2" cross CrossVersion.full),
+     ThisBuild / scalacOptions += "-Vstatistics",
+   )
+ )

You can also use project-scoped settings if you want to profile a particular project:

lazy val myproject = project
  .settings(
+   addCompilerPlugin("ch.epfl.scala" %% "scalac-profiling" % "1.1.2" cross CrossVersion.full),
+   ThisBuild / scalacOptions += "-Vstatistics",
  )

Extend the configuration

There are several compiler plugin options to enable to enrichment of analysis capabilities. All the following options are prepended by the -P:scalac-profiling:.

NameDescription
generate-global-flamegraphCreates a global flamegraph of implicit searches for all compilation units. Use the -P:scalac-profiling:cross-target option to manage the target directory for the resulting flamegraph file, otherwise, the SBT target directory will be picked.
generate-macro-flamegraphGenerate a flamegraph for macro expansions. The flamegraph for implicit searches is enabled by default.
generate-profiledbGenerate profiledb.
print-failed-implicit-macro-candidatesPrint trees of all failed implicit searches that triggered a macro expansion.
print-search-resultPrint the result retrieved by an implicit search. Example: -P:scalac-profiling:print-search-result:$MACRO_ID.
show-concrete-implicit-tparamsUse more concrete type parameters in the implicit search flamegraph. Note that it may change the shape of the flamegraph.
show-profilesShow implicit searches and macro expansions by type and call-site.
sourcerootTell the plugin what is the source directory of the project. Example: -P:scalac-profiling:sourceroot:$PROJECT_BASE_DIR.
cross-targetTell the plugin what is the cross target directory of the project. Example: -P:scalac-profiling:cross-target:$PROJECT_TARGET.
← What is scalac-profiling?Usage →
scalac-profiling
Docs
InstallationUsage
Community
Chat on DiscordDiscuss on Scala Users
More
GitHub
Copyright © 2025 Scala Center