mirror of
https://github.com/tw93/Mole.git
synced 2026-02-10 23:34:16 +00:00
refactor: improve CPU/GPU display for better readability
- Keep showing top 3 busiest cores instead of all cores - Simplify core info display: 'Load x.xx / x.xx / x.xx (8P+4E)' - Remove excessive comments in GPU card rendering - Add missing sort import for core sorting logic Co-authored-by: bsisduck <bluescreen@duck.com>
This commit is contained in:
BIN
bin/status-go
BIN
bin/status-go
Binary file not shown.
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -186,9 +187,8 @@ func renderCPUCard(cpu CPUStatus) cardData {
|
|||||||
var lines []string
|
var lines []string
|
||||||
lines = append(lines, fmt.Sprintf("Total %s %5.1f%%", progressBar(cpu.Usage), cpu.Usage))
|
lines = append(lines, fmt.Sprintf("Total %s %5.1f%%", progressBar(cpu.Usage), cpu.Usage))
|
||||||
|
|
||||||
// Show core topology info if available (Apple Silicon)
|
|
||||||
if cpu.PCoreCount > 0 && cpu.ECoreCount > 0 {
|
if cpu.PCoreCount > 0 && cpu.ECoreCount > 0 {
|
||||||
lines = append(lines, subtleStyle.Render(fmt.Sprintf("%.2f / %.2f / %.2f (%dP + %dE cores)",
|
lines = append(lines, subtleStyle.Render(fmt.Sprintf("Load %.2f / %.2f / %.2f (%dP+%dE)",
|
||||||
cpu.Load1, cpu.Load5, cpu.Load15, cpu.PCoreCount, cpu.ECoreCount)))
|
cpu.Load1, cpu.Load5, cpu.Load15, cpu.PCoreCount, cpu.ECoreCount)))
|
||||||
} else {
|
} else {
|
||||||
lines = append(lines, subtleStyle.Render(fmt.Sprintf("%.2f / %.2f / %.2f (%d cores)",
|
lines = append(lines, subtleStyle.Render(fmt.Sprintf("%.2f / %.2f / %.2f (%d cores)",
|
||||||
@@ -198,23 +198,23 @@ func renderCPUCard(cpu CPUStatus) cardData {
|
|||||||
if cpu.PerCoreEstimated {
|
if cpu.PerCoreEstimated {
|
||||||
lines = append(lines, subtleStyle.Render("Per-core data unavailable (using averaged load)"))
|
lines = append(lines, subtleStyle.Render("Per-core data unavailable (using averaged load)"))
|
||||||
} else if len(cpu.PerCore) > 0 {
|
} else if len(cpu.PerCore) > 0 {
|
||||||
// Apple Silicon: Group cores into P-CPU and E-CPU
|
type coreUsage struct {
|
||||||
if cpu.PCoreCount > 0 && cpu.ECoreCount > 0 {
|
idx int
|
||||||
// P-cores (Performance) come first
|
val float64
|
||||||
lines = append(lines, titleStyle.Render("P-CPU"))
|
}
|
||||||
for i := 0; i < cpu.PCoreCount && i < len(cpu.PerCore); i++ {
|
var cores []coreUsage
|
||||||
lines = append(lines, fmt.Sprintf("Core%-2d %s %5.1f%%", i+1, progressBar(cpu.PerCore[i]), cpu.PerCore[i]))
|
for i, v := range cpu.PerCore {
|
||||||
}
|
cores = append(cores, coreUsage{i, v})
|
||||||
// E-cores (Efficiency) come after P-cores
|
}
|
||||||
lines = append(lines, titleStyle.Render("E-CPU"))
|
sort.Slice(cores, func(i, j int) bool { return cores[i].val > cores[j].val })
|
||||||
for i := cpu.PCoreCount; i < cpu.PCoreCount+cpu.ECoreCount && i < len(cpu.PerCore); i++ {
|
|
||||||
lines = append(lines, fmt.Sprintf("Core%-2d %s %5.1f%%", i+1, progressBar(cpu.PerCore[i]), cpu.PerCore[i]))
|
maxCores := 3
|
||||||
}
|
if len(cores) < maxCores {
|
||||||
} else {
|
maxCores = len(cores)
|
||||||
// Non-Apple Silicon: Show all cores without grouping
|
}
|
||||||
for i, v := range cpu.PerCore {
|
for i := 0; i < maxCores; i++ {
|
||||||
lines = append(lines, fmt.Sprintf("Core%-2d %s %5.1f%%", i+1, progressBar(v), v))
|
c := cores[i]
|
||||||
}
|
lines = append(lines, fmt.Sprintf("Core%-2d %s %5.1f%%", c.idx+1, progressBar(c.val), c.val))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,17 +227,14 @@ func renderGPUCard(gpus []GPUStatus) cardData {
|
|||||||
lines = append(lines, subtleStyle.Render("No GPU detected"))
|
lines = append(lines, subtleStyle.Render("No GPU detected"))
|
||||||
} else {
|
} else {
|
||||||
for _, g := range gpus {
|
for _, g := range gpus {
|
||||||
// Line 1: Usage bar (if available)
|
|
||||||
if g.Usage >= 0 {
|
if g.Usage >= 0 {
|
||||||
lines = append(lines, fmt.Sprintf("Total %s %5.1f%%", progressBar(g.Usage), g.Usage))
|
lines = append(lines, fmt.Sprintf("Total %s %5.1f%%", progressBar(g.Usage), g.Usage))
|
||||||
}
|
}
|
||||||
// Line 2: GPU name and core count
|
|
||||||
coreInfo := ""
|
coreInfo := ""
|
||||||
if g.CoreCount > 0 {
|
if g.CoreCount > 0 {
|
||||||
coreInfo = fmt.Sprintf(" (%d cores)", g.CoreCount)
|
coreInfo = fmt.Sprintf(" (%d cores)", g.CoreCount)
|
||||||
}
|
}
|
||||||
lines = append(lines, subtleStyle.Render(g.Name+coreInfo))
|
lines = append(lines, subtleStyle.Render(g.Name+coreInfo))
|
||||||
// Line 3: Hint for sudo if usage unavailable
|
|
||||||
if g.Usage < 0 {
|
if g.Usage < 0 {
|
||||||
lines = append(lines, subtleStyle.Render("Run with sudo for usage metrics"))
|
lines = append(lines, subtleStyle.Render("Run with sudo for usage metrics"))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user