From 5bdf94da4a817c0b6a6e4e5548e4be7f88af7b2a Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 23 Aug 2018 17:29:42 -0400 Subject: [PATCH] calculate internal fragmentation for size classes --- calculate_waste.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/calculate_waste.py b/calculate_waste.py index d8d473c..7a87204 100755 --- a/calculate_waste.py +++ b/calculate_waste.py @@ -11,12 +11,24 @@ size_classes = [ 10240, 12288, 14336, 16384 ] +print("size class", "worst case internal fragmentation", sep=", ") + +print(16, "100%", sep=", ") +for i in range(len(size_classes) - 1): + size_class = size_classes[i + 1] + + worst_case = size_classes[i] + 1 + used = worst_case / size_class + print(size_class, str(100 - used * 100) + "%", sep=", ") + def page_align(size): return (size + 4095) & ~4095 max_bits = 256 max_page_span = 16 +print() + print("maximum bitmap size is {}-bit".format(max_bits)) print("maximum page span size is {} ({})".format(max_page_span, max_page_span * 4096))