reactific / hotspot-profiler

A simple manual profiler for manually instrumenting hot spots to track performance issues in Scala code.

Version Matrix

License Build Status Coverage Status Release Downloads Join the chat at

Reactific HotSpot Profiler

This is a very simplistic tool aimed at focusing in on a particular hot spot where sampled profiling just isn't good enough. It is quite simple to use, just like this:

import com.reactific.hsp.Profiler

def myHotSpot = Profiler.profile("myHotSpot") {

The execution time of myHotSpot will be recorded, separately in each thread. After the test is over, you can write code to extract the results. To get a simple summary of the values, you can:

val (count, sum) = Profiler.get_one_item("myHotSpot")

to extract the number of invocations (count) and the sum of the execution times (sum) for the myHotSpot function. If you need fancier reporting you can also do something like:

log.debug(s"Profiling Results:\n${Profiler.format_profile_data.toString()}")

to print out all the results in a nested format for each thread.

Overhead is about 50 microseconds for each Profiler.profile call if profiling is enabled. When it is disabled, overhead is exactly one boolean dereference in an if statement and a function call (minimal).