MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / find_unit_of_cache_size

Function find_unit_of_cache_size

scripts/utils/str_utils.py:29–43  ·  view source on GitHub ↗

convert a cache size in int (byte) to a size with unit

(cache_size: int)

Source from the content-addressed store, hash-verified

27
28
29def find_unit_of_cache_size(cache_size: int) -> Tuple[int, str]:
30 """convert a cache size in int (byte) to a size with unit"""
31
32 size_unit, size_unit_str = 1, "B"
33 if cache_size > 1024 * 1024 * 1024:
34 size_unit = 1024 * 1024 * 1024
35 size_unit_str = "GiB"
36 elif cache_size > 1024 * 1024:
37 size_unit = 1024 * 1024
38 size_unit_str = "MiB"
39 elif cache_size > 1024:
40 size_unit = 1024
41 size_unit_str = "KiB"
42
43 return size_unit, size_unit_str

Callers 2

plot_mrc_sizeFunction · 0.90
plot_mrc_sizeFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected