Profiling scala code in 2018


#1

I’d like to profile some code I’ve written, to find out how much time is being spent in which functions.

Simple logging isn’t enough to help me as a lot of processing is being done in parallel, which makes it hard to track this manually.

I’ve done some googling and there doesn’t seem to be a standard answer for this. There’s http://scalameter.github.io/ but it only lets you write performance tests, it doesn’t seem like it lets you just run something and give a breakdown of which functions took the most time.

There’s also VisualVM but there are conflicting reports on whether it works with scala or not.

Something that works with Intellij would be ideal.

Any ideas?


#2

I’ve just tried VisualVM and its IntelliJ plugin, and that works pretty well.

It doesn’t seem to have a way to record time in specific functions, but it does let you see what’s taking up CPU / memory, and tracking usage might be a way to track the time in specific functions.


#3

You should also try out these alternatives:


#4

I think the best tool I’ve used so far is JProfiler, however the license is quite expensive. They do offer a 1 month free trial though. Also, the next version of IntelliJ is going to support flame graphs run from the IDE, which will be amazing!

Edit:
@aliakhtar see https://blog.jetbrains.com/idea/2018/09/intellij-idea-2018-3-eap-git-submodules-jvm-profiler-macos-and-linux-and-more/