Documentation ¶
Overview ¶
Package cpulimit implements a simple CPU usage instrument that communicates whether the CPU is running "cold" or "hot" via two distinct channels. It is intended to be used for self-restraining resource-hungry programs.
The author is well aware that all modern operating systems provide means of providing the task scheduler with priority hints (e.g. nice(), SetPriorityClass(). This package is intended to help with limiting actual CPU usage, e.g. to work around system administrators who are scared by high CPU load even if the load is predominantly caused by low-priority processes that do actual work.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Limiter ¶
type Limiter struct { // MaxCPUUsage is the CPU usage threshold, in percent, above which // the CPU is considered as "hot". This value can be set while the // measurement process is running. Default: 50.0 MaxCPUUsage float64 // SwitchPeriod determines how often the Limiter decides whether // the CPU is "hot" or "cold". Default: 1 second SwitchPeriod time.Duration // MeasurePeriod determines how often CPU usage is // measured. Default: SwitchPeriod / 4 (if MeasurePeriod >= // SwitchPeriod/2) MeasurePeriod time.Duration // For deciding whether the CPU is "hot" or "cold", a rolling // average over MeasureDuration is taken. Default: 10 * // SwitchPeriod (if MeasureDuration <= SwitchPeriod) MeasureDuration time.Duration // The rolling average and the current CPU usage will be sent to H // ("hot") whenever average CPU usage over the Measurements period // is equal to or higher than MaxCPUUsage. H chan Info // The rolling average and the current CPU usage will be sent to C // ("cold") whenever average CPU usage over the Measurements // period is below MaxCPUUsage. C chan Info // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.