compare_sizes: compare to original program size

This commit is contained in:
Théophile Bastian 2018-07-02 12:44:27 +02:00
parent aa7b43eb27
commit 4181dd828a

View file

@ -142,9 +142,11 @@ def main():
col_names = [ col_names = [
'Shared object', 'Shared object',
'Orig prog size',
'Orig eh_frame', 'Orig eh_frame',
'Gen eh_elf .text', 'Gen eh_elf .text',
'+ .rodata', '+ .rodata',
'% of prog size',
'Growth', 'Growth',
] ]
@ -161,20 +163,27 @@ def main():
'{:<' + col_len[1] + '} ' '{:<' + col_len[1] + '} '
'{:<' + col_len[2] + '} ' '{:<' + col_len[2] + '} '
'{:<' + col_len[3] + '} ' '{:<' + col_len[3] + '} '
'{:<' + col_len[4] + '}') '{:<' + col_len[4] + '} '
'{:<' + col_len[5] + '} '
'{:<' + col_len[6] + '}')
row_format = ('{:>' + col_len[0] + '} ' row_format = ('{:>' + col_len[0] + '} '
'{:>' + col_len[1] + '} ' '{:>' + col_len[1] + '} '
'{:>' + col_len[2] + '} ' '{:>' + col_len[2] + '} '
'{:>' + col_len[3] + '} ' '{:>' + col_len[3] + '} '
'{:>' + col_len[4] + '}') '{:>' + col_len[4] + '} '
'{:>' + col_len[5] + '} '
'{:>' + col_len[6] + '}')
print(header_format.format( print(header_format.format(
col_names[0], col_names[0],
col_names[1], col_names[1],
col_names[2], col_names[2],
col_names[3], col_names[3],
col_names[4], col_names[4],
col_names[5],
col_names[6],
)) ))
total_program_size = 0
total_eh_frame_size = 0 total_eh_frame_size = 0
total_eh_elf_text_size = 0 total_eh_elf_text_size = 0
total_eh_elf_size = 0 total_eh_elf_size = 0
@ -183,6 +192,10 @@ def main():
elf_sections = get_elf_sections(obj.elf) elf_sections = get_elf_sections(obj.elf)
eh_elf_sections = get_elf_sections(obj.eh_elf) eh_elf_sections = get_elf_sections(obj.eh_elf)
text_size = get_or_default(
elf_sections, '.text', {'size': 0})['size']
rodata_size = get_or_default(
elf_sections, '.rodata', {'size': 0})['size']
eh_frame_size = get_or_default( eh_frame_size = get_or_default(
elf_sections, '.eh_frame', {'size': 0})['size'] elf_sections, '.eh_frame', {'size': 0})['size']
eh_elf_text_size = get_or_default( eh_elf_text_size = get_or_default(
@ -191,15 +204,20 @@ def main():
get_or_default( get_or_default(
eh_elf_sections, '.rodata', {'size': 0})['size'] eh_elf_sections, '.rodata', {'size': 0})['size']
program_size = text_size + rodata_size
total_program_size += program_size
total_eh_frame_size += eh_frame_size total_eh_frame_size += eh_frame_size
total_eh_elf_text_size += eh_elf_text_size total_eh_elf_text_size += eh_elf_text_size
total_eh_elf_size += eh_elf_size total_eh_elf_size += eh_elf_size
print(row_format.format( print(row_format.format(
displayed_name_filter(obj), displayed_name_filter(obj),
format_size(program_size),
format_size(eh_frame_size), format_size(eh_frame_size),
format_size(eh_elf_text_size), format_size(eh_elf_text_size),
format_size(eh_elf_size), format_size(eh_elf_size),
'{:.2f}'.format(eh_elf_size / program_size * 100),
'{:.2f}'.format(eh_elf_size / eh_frame_size))) '{:.2f}'.format(eh_elf_size / eh_frame_size)))
# Checking for missed big sections # Checking for missed big sections
@ -212,9 +230,11 @@ def main():
print(row_format.format( print(row_format.format(
'Total', 'Total',
format_size(total_program_size),
format_size(total_eh_frame_size), format_size(total_eh_frame_size),
format_size(total_eh_elf_size), format_size(total_eh_elf_size),
format_size(total_eh_elf_text_size), format_size(total_eh_elf_text_size),
'{:.2f}'.format(total_eh_elf_size / total_program_size * 100),
'{:.2f}'.format(total_eh_elf_size / total_eh_frame_size))) '{:.2f}'.format(total_eh_elf_size / total_eh_frame_size)))