From c60fbfb0295af0640fda0371af17a9466aaba323 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sun, 26 Aug 2018 06:21:09 -0400 Subject: [PATCH] output markdown table from calculate_waste --- calculate_waste.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/calculate_waste.py b/calculate_waste.py index 016a00f..173d148 100755 --- a/calculate_waste.py +++ b/calculate_waste.py @@ -24,25 +24,26 @@ size_class_slots = [ 6, 5, 4, 4 ] -print("size class", "worst case internal fragmentation", sep=", ") +fragmentation = [100] -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=", ") + fragmentation.append(100 - used * 100); def page_align(size): return (size + 4095) & ~4095 -print() -print("size class", "slab slots", "slab size", "worst case internal fragmentation for slabs", sep=", ") -for size, slots in zip(size_classes, size_class_slots): +print("| ", end="") +print("size class", "worst case internal fragmentation", "slab slots", "slab size", "worst case internal fragmentation for slabs", sep=" | ", end=" |\n") +print("| ", end='') +print("-", "-", "-", "-", "-", sep=" | ", end=" |\n") +for size, slots, fragmentation in zip(size_classes, size_class_slots, fragmentation): used = size * slots real = page_align(used) - print(size, slots, real, str(100 - used / real * 100) + "%", sep=", ") + print("| ", end='') + print(size, str(fragmentation) + "%", slots, real, str(100 - used / real * 100) + "%", sep=" | ", end=" |\n") if len(argv) < 2: exit()