mirror of
https://github.com/henrygd/beszel.git
synced 2026-04-15 01:11:50 +02:00
web: refactor gpu code for slighly better perf
This commit is contained in:
@@ -400,16 +400,34 @@ export default memo(function SystemDetail({ id }: { id: string }) {
|
|||||||
const containerFilterBar = containerData.length ? <FilterBar /> : null
|
const containerFilterBar = containerData.length ? <FilterBar /> : null
|
||||||
|
|
||||||
const dataEmpty = !chartLoading && chartData.systemStats.length === 0
|
const dataEmpty = !chartLoading && chartData.systemStats.length === 0
|
||||||
const lastGpuVals = Object.values(systemStats.at(-1)?.stats.g ?? {})
|
const lastGpus = systemStats.at(-1)?.stats?.g
|
||||||
const hasGpuData = lastGpuVals.length > 0
|
|
||||||
const hasGpuPowerData = systemStats.some((record) => {
|
let hasGpuData = false
|
||||||
const gpus = record.stats?.g
|
let hasGpuEnginesData = false
|
||||||
if (!gpus) {
|
let hasGpuPowerData = false
|
||||||
return false
|
|
||||||
|
if (lastGpus) {
|
||||||
|
// check if there are any GPUs with engines
|
||||||
|
for (const id in lastGpus) {
|
||||||
|
hasGpuData = true
|
||||||
|
if (lastGpus[id].e !== undefined) {
|
||||||
|
hasGpuEnginesData = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
return Object.values(gpus).some((gpu) => gpu.p !== undefined || gpu.pp !== undefined)
|
}
|
||||||
})
|
// check if there are any GPUs with power data
|
||||||
const hasGpuEnginesData = lastGpuVals.some((gpu) => gpu.e !== undefined)
|
for (let i = 0; i < systemStats.length && !hasGpuPowerData; i++) {
|
||||||
|
const gpus = systemStats[i].stats?.g
|
||||||
|
if (!gpus) continue
|
||||||
|
for (const id in gpus) {
|
||||||
|
if (gpus[id].p !== undefined || gpus[id].pp !== undefined) {
|
||||||
|
hasGpuPowerData = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const isLinux = !(details?.os ?? system.info?.os)
|
const isLinux = !(details?.os ?? system.info?.os)
|
||||||
const isPodman = details?.podman ?? system.info?.p ?? false
|
const isPodman = details?.podman ?? system.info?.p ?? false
|
||||||
|
|
||||||
@@ -721,8 +739,9 @@ export default memo(function SystemDetail({ id }: { id: string }) {
|
|||||||
<GpuEnginesChart chartData={chartData} />
|
<GpuEnginesChart chartData={chartData} />
|
||||||
</ChartCard>
|
</ChartCard>
|
||||||
)}
|
)}
|
||||||
{Object.keys(systemStats.at(-1)?.stats.g ?? {}).map((id) => {
|
{lastGpus &&
|
||||||
const gpu = systemStats.at(-1)?.stats.g?.[id] as GPUData
|
Object.keys(lastGpus).map((id) => {
|
||||||
|
const gpu = lastGpus[id] as GPUData
|
||||||
return (
|
return (
|
||||||
<div key={id} className="contents">
|
<div key={id} className="contents">
|
||||||
<ChartCard
|
<ChartCard
|
||||||
|
|||||||
Reference in New Issue
Block a user