Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Profiling sbt builds

Tags:

scala

sbt

I have an sbt build that takes ages. It's big and complex and it's hard to know where to start cleaning it up. It seems like sbt retains a lot of metadata about the structure of the build, with interdependencies, named tasks, scoping, and so on. With all this metadata, it seems like it would be quite easy to jump in and measure how much time each distinct task, with scope, takes. Doing this in code rather than based on log messages not only feels cleaner, but has the advantage of dealing nicely with concurrent builds and other complicated stuff that could cause the log times to be misleading.

Are there any facilities to do this currently? It doesn't feel like something we could do in a "user" build, but perhaps an SBT plugin could hook a task starter and maintain/produce a big report of timings at the end. It would really help focus my efforts on improving the slow things without wasting time on things that happen instantly.

like image 420
Mysterious Dan Avatar asked Jun 20 '13 18:06

Mysterious Dan


1 Answers

I had absolutely the same problem some time ago. Look at source code of https://github.com/sbt-android-mill/sbt-android-mill

Here is announce - https://groups.google.com/forum/#!msg/scala-on-android/TsmmJA4uvQ4/LMvAxuovXoMJ Pay attention to time field in SBT log.

Few wrappers + something like stopwatch(in dependencies) and you will have attractive HTML reports with profiling statistics.

like image 69
Ezhik Avatar answered Oct 24 '22 00:10

Ezhik