Skip to content

Commit

Permalink
chore: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
VihasMakwana committed Nov 25, 2024
1 parent ea78b1d commit 7955534
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions metric/cpu/metrics_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,23 @@ func Get(_ resolve.Resolver) (CPUMetrics, error) {
var idle, kernel, user time.Duration
globalMetrics.list = make([]CPU, len(userRawData))
for i := 0; i < len(globalMetrics.list); i++ {
idleTimeNs := time.Duration(idleRawData[i].RawValue.FirstValue * 100)
kernelTimeNs := time.Duration(kernelRawData[i].RawValue.FirstValue * 100)
userTimeNs := time.Duration(userRawData[i].RawValue.FirstValue * 100)
idleTimeMs := time.Duration(idleRawData[i].RawValue.FirstValue*100) / time.Millisecond
kernelTimeMs := time.Duration(kernelRawData[i].RawValue.FirstValue*100) / time.Millisecond
userTimeMs := time.Duration(userRawData[i].RawValue.FirstValue*100) / time.Millisecond

globalMetrics.list[i].Idle = opt.UintWith(uint64(idleTimeNs / time.Millisecond))
globalMetrics.list[i].Sys = opt.UintWith(uint64(kernelTimeNs / time.Millisecond))
globalMetrics.list[i].User = opt.UintWith(uint64(userTimeNs / time.Millisecond))
globalMetrics.list[i].Idle = opt.UintWith(uint64(idleTimeMs))
globalMetrics.list[i].Sys = opt.UintWith(uint64(kernelTimeMs))
globalMetrics.list[i].User = opt.UintWith(uint64(userTimeMs))

// add the per-cpu time to track the total time spent by system
idle += idleTimeNs
kernel += kernelTimeNs
user += userTimeNs
idle += idleTimeMs
kernel += kernelTimeMs
user += userTimeMs
}

globalMetrics.totals.Idle = opt.UintWith(uint64(idle / time.Millisecond))
globalMetrics.totals.Sys = opt.UintWith(uint64(kernel / time.Millisecond))
globalMetrics.totals.User = opt.UintWith(uint64(user / time.Millisecond))
globalMetrics.totals.Idle = opt.UintWith(uint64(idle))
globalMetrics.totals.Sys = opt.UintWith(uint64(kernel))
globalMetrics.totals.User = opt.UintWith(uint64(user))

return globalMetrics, nil
}
Expand Down

0 comments on commit 7955534

Please sign in to comment.