예제 #1
0
    def _DescribeSizeInfo(self, size_info):
        desc_list = []
        # Describe |build_config| and each container. If there is only one container
        # then support legacy output by reporting |build_config| as part of the
        # first container's metadata.
        if len(size_info.containers) > 1:
            desc_list.append(('Build Configs:', ))
            desc_list.append('    %s' % line
                             for line in DescribeDict(size_info.build_config))
            containers = size_info.containers
        else:
            containers = [
                models.Container(
                    name='',
                    metadata=size_info.metadata_legacy,
                    section_sizes=size_info.containers[0].section_sizes)
            ]
        for c in containers:
            if c.name:
                desc_list.append(('', ))
                desc_list.append(('Container <%s>' % c.name, ))
            desc_list.append(('Metadata:', ))
            desc_list.append('    %s' % line
                             for line in DescribeDict(c.metadata))
            unsummed_sections, summed_sections = c.ClassifySections()
            desc_list.append(
                self._DescribeSectionSizes(unsummed_sections, summed_sections,
                                           c.section_sizes))

        if self.verbose:
            desc_list.append(('', ))
            desc_list.append(data_quality.DescribeSizeInfoCoverage(size_info))
        desc_list.append(('', ))
        desc_list.append(self.GenerateLines(size_info.symbols))
        return itertools.chain.from_iterable(desc_list)
예제 #2
0
    def _SizeStats(self, size_info=None):
        """Prints some statistics for the given size info.

    Args:
      size_info: Defaults to size_infos[0].
    """
        size_info = size_info or self._size_infos[0]
        describe.WriteLines(data_quality.DescribeSizeInfoCoverage(size_info),
                            sys.stdout.write)
예제 #3
0
    def _DoArchiveTest(self,
                       use_output_directory=True,
                       use_elf=False,
                       use_apk=False,
                       use_minimal_apks=False,
                       use_pak=False,
                       use_aux_elf=False,
                       ignore_linker_map=False,
                       debug_measures=False,
                       include_padding=False):
        with tempfile.NamedTemporaryFile(suffix='.size') as temp_file:
            self._DoArchive(temp_file.name,
                            use_output_directory=use_output_directory,
                            use_elf=use_elf,
                            use_apk=use_apk,
                            use_minimal_apks=use_minimal_apks,
                            use_pak=use_pak,
                            use_aux_elf=use_aux_elf,
                            ignore_linker_map=ignore_linker_map,
                            debug_measures=debug_measures,
                            include_padding=include_padding)
            size_info = archive.LoadAndPostProcessSizeInfo(temp_file.name)
        # Check that saving & loading is the same as directly parsing.
        expected_size_info = self._CloneSizeInfo(
            use_output_directory=use_output_directory,
            use_elf=use_elf,
            use_apk=use_apk,
            use_minimal_apks=use_minimal_apks,
            use_pak=use_pak,
            use_aux_elf=use_aux_elf,
            ignore_linker_map=ignore_linker_map)
        self.assertEqual(_AllMetadata(expected_size_info),
                         _AllMetadata(size_info))
        # Don't cluster.
        expected_size_info.symbols = expected_size_info.raw_symbols
        size_info.symbols = size_info.raw_symbols
        expected = list(
            describe.GenerateLines(expected_size_info, verbose=True))
        actual = list(describe.GenerateLines(size_info, verbose=True))
        self.assertEqual(expected, actual)

        sym_strs = (repr(sym) for sym in size_info.symbols)
        stats = data_quality.DescribeSizeInfoCoverage(size_info)
        if len(size_info.containers) == 1:
            # If there's only one container, merge the its metadata into build_config.
            merged_data_desc = describe.DescribeDict(size_info.metadata_legacy)
        else:
            merged_data_desc = describe.DescribeDict(size_info.build_config)
            for m in _AllMetadata(size_info):
                merged_data_desc.extend(describe.DescribeDict(m))
        return itertools.chain(merged_data_desc, stats, sym_strs)