diff options
| author | Jacob Richman <[email protected]> | 2025-05-30 22:18:01 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-05-30 15:18:01 -0700 |
| commit | 01768d7759b81a0f1483c751206f6afcae6fc505 (patch) | |
| tree | befda8dfe9807bfee805e291fa203cfe8dfefe29 /packages/cli/src/ui/utils/formatters.ts | |
| parent | 3291ffbe099f2fdc8f88a0c1bb06fb43b65326a9 (diff) | |
feat: add --show_memory_usage flag to display memory usage in status bar (#606)
Diffstat (limited to 'packages/cli/src/ui/utils/formatters.ts')
| -rw-r--r-- | packages/cli/src/ui/utils/formatters.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/packages/cli/src/ui/utils/formatters.ts b/packages/cli/src/ui/utils/formatters.ts new file mode 100644 index 00000000..ab02160e --- /dev/null +++ b/packages/cli/src/ui/utils/formatters.ts @@ -0,0 +1,16 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +export const formatMemoryUsage = (bytes: number): string => { + const gb = bytes / (1024 * 1024 * 1024); + if (bytes < 1024 * 1024) { + return `${(bytes / 1024).toFixed(1)} KB`; + } + if (bytes < 1024 * 1024 * 1024) { + return `${(bytes / (1024 * 1024)).toFixed(1)} MB`; + } + return `${gb.toFixed(2)} GB`; +}; |
