Process.cpuPercent

double cpuPercent(Duration interval = Duration.zero) @safe

Gets CPU usage percentage.

Parameters

intervalDuration to wait before calculating percentage. If 0, returns percentage since last call.

Returns

CPU usage as a percentage (0.0 to 100.0 * cpu_count).

Example:

auto proc = Process.current();
auto cpuPct = proc.cpuPercent(1.seconds);
writeln("CPU usage: ", cpuPct, "%");