Open History to see the last commit
1import type { HostPressureAgent } from "@t3tools/contracts";
2import { part, plural, type useGT } from "gt-react-native";
3
4import { formatBytes } from "../../lib/formatBytes";
5
6/** Memory or cores, whichever the server ranked agents by. */
7export function hostPressureAgentUsage(
8 gt: ReturnType<typeof useGT>,
9 agent: HostPressureAgent,
10 rankedBy: "memory" | "cpu",
11): string {
12 return rankedBy === "memory" || agent.cpuCores === null
13 ? formatBytes(agent.memoryBytes)
14 : gt`${plural(
15 { count: agent.cpuCores },
16 {
17 one: part`${{ count: agent.cpuCores }} core`,
18 other: part`${{ count: agent.cpuCores }} cores`,
19 },
20 )}`;
21}