This module contains utility functions for easy measurement and calculation of scheduler utilization. It act as a wrapper around the more primitive API erlang:statistics(scheduler_wall_time).
The simplest usage is to call the blocking scheduler:utilization(Seconds).
For non blocking and/or continuous calculation of scheduler utilization, the recommended usage is:
First call erlang:system_flag(scheduler_wall_time,true) to enable scheduler wall time measurements.
Call get_sample/0 to collect samples with some time in between.
Call utilization/2 to calculate the scheduler utilization in the interval between two samples.
When done call erlang:system_flag(scheduler_wall_time,false) to disable scheduler wall time measurements and avoid unecessary cpu overhead.
To get correct values from utilization/2, it is important that scheduler_wall_time is kept enabled during the entire interval between the two samples. To ensure this, the process that called erlang:system_flag(scheduler_wall_time,true) must be kept alive, as scheduler_wall_time will automatically be disabled if it terminates.