perf: gather facts gpu info

This commit is contained in:
feng
2025-04-22 10:42:10 +08:00
committed by feng626
parent cad15986bf
commit 49c80cd76b
2 changed files with 62 additions and 10 deletions

View File

@@ -50,23 +50,75 @@ export default {
return cellValue return cellValue
}, },
viewText() { viewText() {
const cpuCount = this.items['cpu_count'] const cpuCount = Number(this.items['cpu_count'] || 0)
const cpuCores = this.items['cpu_cores'] const cpuCores = Number(this.items['cpu_cores'] || 0)
const cpuVcpus = this.items['cpu_vcpus'] const cpuVcpus = Number(this.items['cpu_vcpus'] || 0)
const memory = this.items['memory'] const memory = Number(this.items['memory'] || 0)
const diskTotal = this.items['disk_total'] const diskTotal = Number(this.items['disk_total'] || 0)
const rawCpuModel = this.items['cpu_model']
const rawGpuModel = this.items['gpu_model']
let summary = ''
if (cpuCount) { if (cpuCount) {
let text = `${cpuVcpus || cpuCores * cpuCount} Core` const coreCount = cpuVcpus || (cpuCores * cpuCount)
summary = `${coreCount} Core`
if (memory) { if (memory) {
text += ` ${memory}G` summary += ` ${Math.round(memory)}G`
} }
if (diskTotal) { if (diskTotal) {
text += ` ${diskTotal}G` summary += ` ${Math.round(diskTotal)}G`
} }
return text
const cpuModel = this.formatCpuModel(rawCpuModel)
if (cpuModel) {
summary += ` (${cpuModel})`
} }
if (rawGpuModel) {
const gpu = this.formatGpuModel(rawGpuModel)
summary += ` ${gpu}`
}
return summary
}
return this.items?.distribution || '-' return this.items?.distribution || '-'
} }
},
methods: {
formatCpuModel(raw) {
if (!raw) return ''
const match = raw.match(/^([^\s]+)\s*(x\d+)?$/)
let base = match?.[1] || raw
const suffix = match?.[2] || ''
base = base
.replace(/GenuineIntel/i, '')
.replace(/\b\d+(st|nd|rd|th)? Gen\b/i, '')
.replace(/\(R\)/g, '')
.replace(/\(TM\)/g, '')
.replace(/\s+/g, ' ')
.trim()
return `${base}${suffix}`
},
formatGpuModel(raw) {
if (!raw) return ''
const match = raw.match(/(.+?),\s*(\d+),\s*([\d.]+)(?:\s*x(\d+))?/)
if (match) {
const [, model, vramMb, driverVersion, countStr] = match
const count = countStr ? parseInt(countStr) : 1
const vramGb = Math.round(parseInt(vramMb) / 1024)
const label = `${model} (${vramGb}GB, Driver ${driverVersion})`
return count > 1 ? `${label} x${count}` : label
}
return raw // fallback
}
} }
} }
</script> </script>

View File

@@ -22,7 +22,7 @@ export default {
fields: [ fields: [
'vendor', 'model', 'sn', 'cpu_model', 'cpu_count', 'vendor', 'model', 'sn', 'cpu_model', 'cpu_count',
'cpu_cores', 'cpu_vcpus', 'memory', 'disk_total', 'cpu_cores', 'cpu_vcpus', 'memory', 'disk_total',
'distribution', 'distribution_version', 'arch' 'distribution', 'distribution_version', 'arch', 'gpu_model'
] ]
} }
}, },