MCPcopy Create free account
hub / github.com/Loafter/WebTop / mesureCPU

Method mesureCPU

SystemMonitorDispatcher.go:32–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30}
31
32func (serviceStateDispatcher *SystemMonitorDispatcher) mesureCPU() {
33 for {
34 serviceStateDispatcher.lastCPUAverage = GetCPUAverage(serviceStateDispatcher.lastCPUSample, GetCPUSample())
35 serviceStateDispatcher.lastCPUSample = GetCPUSample()
36 time.Sleep(500 * time.Millisecond)
37 secondLastRequest := time.Now().Sub(serviceStateDispatcher.lastRequestTime)
38 if secondLastRequest.Seconds() > 5 {
39
40 log.Println("info: sleep mesure cpu job")
41 serviceStateDispatcher.mesureJob.Stop()
42
43 }
44 }
45}
46
47func (serviceStateDispatcher *SystemMonitorDispatcher) StartMesure() error {
48 serviceStateDispatcher.mesureJob.Job = serviceStateDispatcher.mesureCPU

Callers

nothing calls this directly

Calls 3

GetCPUAverageFunction · 0.85
GetCPUSampleFunction · 0.85
StopMethod · 0.80

Tested by

no test coverage detected