convert a cache size in int (byte) to a size with unit
(cache_size: int)
| 27 | |
| 28 | |
| 29 | def 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 |
no outgoing calls
no test coverage detected