[Part 4/6] feat(telemetry): add memory monitor with activity-aware recording and tests (#8122)

Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
Adrian Arribas
2025-10-08 01:23:17 +02:00
committed by GitHub
parent c195a9aa3b
commit 8cd2ec7c9b
5 changed files with 1160 additions and 1 deletions
+3 -1
View File
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: Apache-2.0
*/
export const bytesToMB = (bytes: number): number => bytes / (1024 * 1024);
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 `${bytesToMB(bytes).toFixed(1)} MB`;
}
return `${gb.toFixed(2)} GB`;
};