cpuPercent

fndouble cpuPercent(Duration interval = Duration.init, bool perCpu = false) @safe

Gets CPU usage percentage.

Parameters

intervalDuration to wait between measurements. If 0, returns instantaneous value.
perCpuIf true, returns percentage per CPU core. If false, returns total percentage.

Returns

CPU usage as a percentage (0.0 to 100.0).

Example:

auto percent = cpuPercent(1.seconds);
writeln("CPU usage: ", percent, "%");