mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
16 lines
373 B
TypeScript
16 lines
373 B
TypeScript
// Helper to convert CPU K8S units to numbers
|
|
|
|
export function cpuUnitsToNumber(cpu: string): number {
|
|
const cpuNum = parseInt(cpu);
|
|
const billion = 1000000 * 1000;
|
|
if (cpu.includes("m")) {
|
|
return cpuNum / 1000;
|
|
}
|
|
if (cpu.includes("u")) {
|
|
return cpuNum / 1000000;
|
|
}
|
|
if (cpu.includes("n")) {
|
|
return cpuNum / billion;
|
|
}
|
|
return parseFloat(cpu);
|
|
} |