Installation
Pick the right version
Scala series | Supported versions | scalac-profiling |
---|---|---|
2.12.x | 2.12.20, 2.12.19, 2.12.18, 2.12.17, 2.12.16, 2.12.15, 2.12.14, 2.12.13 | 1.1.1 |
2.13.x | 2.13.15, 2.13.14, 2.13.13, 2.13.12, 2.13.11, 2.13.10, 2.13.9, 2.13.8, 2.13.7, 2.13.6, 2.13.5 | 1.1.1 |
Add the dependency
Add the scalac compiler plugin into your build:
addCompilerPlugin("ch.epfl.scala" %% "scalac-profiling" % "1.1.1" 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.1" 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.1" 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:
.
Name | Description |
---|---|
generate-global-flamegraph | Creates 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-flamegraph | Generate a flamegraph for macro expansions. The flamegraph for implicit searches is enabled by default. |
generate-profiledb | Generate profiledb. |
print-failed-implicit-macro-candidates | Print trees of all failed implicit searches that triggered a macro expansion. |
print-search-result | Print the result retrieved by an implicit search. Example: -P:scalac-profiling:print-search-result:$MACRO_ID . |
show-concrete-implicit-tparams | Use more concrete type parameters in the implicit search flamegraph. Note that it may change the shape of the flamegraph. |
show-profiles | Show implicit searches and macro expansions by type and call-site. |
sourceroot | Tell the plugin what is the source directory of the project. Example: -P:scalac-profiling:sourceroot:$PROJECT_BASE_DIR . |
cross-target | Tell the plugin what is the cross target directory of the project. Example: -P:scalac-profiling:cross-target:$PROJECT_TARGET . |