I'd like to know why sometimes my build is much slower.
So I've decided to measure the time of long-running taks.
When running pure Scala code, it is quite easy to do so:
def myMethod() = {
val initTime = System.currentTimeMillis
...
val elapsedTime = System.currentTimeMillis-initTime
}
But for tasks like packageBin
or compile
, whose source code I cannot change, I don't know how to measure it, because I cannot control when someTask.value
is run.
Any hint?
Related questions:
add -Dsbt.task.timings=true
to your JAVA_OPTS when launching sbt
For a more complete analysis, you can also use jrudolph/sbt-optimizer/
sbt-optimizer
is an experimental plugin that hooks into sbt's task execution engine and offers a graphical ASCII report once a tree of tasks has been runAdd the plugin to
project/plugins.sbt
:
addSbtPlugin("net.virtual-void" % "sbt-optimizer" % "0.1.2")
and enable it in a project with:
enablePlugins(net.virtualvoid.optimizer.SbtOptimizerPlugin)
Each output line corresponds to one task that has been executed.
- The first time is the total time this task was running.
- The second time displayed in green is the actual execution time.
- The third time displayed in red is time the task wanted to run but was waiting for the global ivy lock.
- The last time displayed in cyan is the time the task was blocked waiting for Ivy downloads.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With