jtpio/jupyterlab-system-monitor

How can I change the memory displaying unit?

sjoh-kw opened this issue · 2 comments

In Readme.md, the example shows the unit of memory usage in GB, but my browser shows in MB.
How can I change this unit?

jtpio commented

Thanks @sjoh-kw.

The unit should automatically be adjusted based on the current usage. See the source for the relevant logic:

export const convertToLargestUnit = (
numBytes: number
): [number, ResourceUsage.MemoryUnit] => {
if (numBytes < MEMORY_UNIT_LIMITS.KB) {
return [numBytes, 'B'];
} else if (
MEMORY_UNIT_LIMITS.KB === numBytes ||
numBytes < MEMORY_UNIT_LIMITS.MB
) {
return [numBytes / MEMORY_UNIT_LIMITS.KB, 'KB'];
} else if (
MEMORY_UNIT_LIMITS.MB === numBytes ||
numBytes < MEMORY_UNIT_LIMITS.GB
) {
return [numBytes / MEMORY_UNIT_LIMITS.MB, 'MB'];
} else if (
MEMORY_UNIT_LIMITS.GB === numBytes ||
numBytes < MEMORY_UNIT_LIMITS.TB
) {
return [numBytes / MEMORY_UNIT_LIMITS.GB, 'GB'];
} else if (
MEMORY_UNIT_LIMITS.TB === numBytes ||
numBytes < MEMORY_UNIT_LIMITS.PB
) {
return [numBytes / MEMORY_UNIT_LIMITS.TB, 'TB'];
} else {
return [numBytes / MEMORY_UNIT_LIMITS.PB, 'PB'];
}
};

jtpio commented

Closing as jupyterlab-system-monitor has now been integrated in jupyter-resource-usage: jupyter-server/jupyter-resource-usage#191

Feel free to open a new issue on the jupyter-resource-usage repo if needed: https://github.com/jupyter-server/jupyter-resource-usage

Thanks!