Minor refactor

This commit is contained in:
Caleb Bassi 2019-03-11 22:52:37 -07:00
parent d38fd3a575
commit ade4f2a623
2 changed files with 9 additions and 9 deletions

View File

@ -37,7 +37,7 @@ type Proc struct {
type ProcWidget struct {
*ui.Table
cpuCount float64
cpuCount int
updateInterval time.Duration
sortMethod ProcSortMethod
groupedProcs []Proc
@ -53,7 +53,7 @@ func NewProcWidget() *ProcWidget {
self := &ProcWidget{
Table: ui.NewTable(),
updateInterval: time.Second,
cpuCount: float64(cpuCount),
cpuCount: cpuCount,
sortMethod: ProcSortCpu,
showGroupedProcs: true,
}
@ -92,9 +92,9 @@ func (self *ProcWidget) update() {
return
}
// can't iterate on the entries directly since we can't modify them that way
// have to iterate over the entry number in order to modify the array in place
for i := range procs {
procs[i].Cpu /= self.cpuCount
procs[i].Cpu /= float64(self.cpuCount)
}
self.ungroupedProcs = procs

View File

@ -30,13 +30,13 @@ func getProcs() ([]Proc, error) {
}
procs[i] = Proc{
int(pid),
command,
cpu / self.cpuCount,
float64(mem),
Pid: int(pid),
CommandName: command,
Cpu: cpu,
Mem: float64(mem),
// getting command args using gopsutil's Cmdline and CmdlineSlice wasn't
// working the last time I tried it, so we're just reusing 'command'
command,
FullCommand: command,
}
}