Open orzel opened 7 months ago
Thanks for letting me know, I will create a PR for the Memory power of 1024 I agree it would be interesting to have an automatic value/unit for the Disk & RAM values, like it is done for Network metrics
Memory power of 1024 is now fixed, I will keep your issue open for the automatic value/unit
While for disk, the kilo/mega/giga are usually power of 1000, for RAM, it's usually power of 1024 that are used.
The code in
library/stats.py:class Memory
uses/ 1000000
everywhere. May i suggest to use instead 1024**2 ?Another, slightly related problem, is that the source hardcode the suffixes (for ex 'M' for ram, 'G' for disk), but that's hardly generic enough. For my use case, ram is in the hundred of G range, and disks are in several dozens of TB.
There's a typical function to handle this (found all around the web):
(note it includes doctests)
I understand this can't be used as is, because the code in
library/stats.py
expects thevalue
andunit
in two different variables, but this can easily be adapted.So typically you would use
human_number(size, 1000)
for disk-related sizes, andhuman_number(size, 1024)
for ram stuff.