コード例 #1
0
def Diff(before, after, sort=False):
    """Diffs two SizeInfo objects. Returns a DeltaSizeInfo."""
    assert isinstance(before, models.SizeInfo)
    assert isinstance(after, models.SizeInfo)
    section_sizes = {
        k: after.section_sizes.get(k, 0) - v
        for k, v in before.section_sizes.items()
    }
    for k, v in after.section_sizes.items():
        if k not in section_sizes:
            section_sizes[k] = v

    symbol_diff = _DiffSymbolGroups(before.raw_symbols, after.raw_symbols)
    ret = models.DeltaSizeInfo(before, after, section_sizes, symbol_diff)

    if sort:
        syms = ret.symbols  # Triggers clustering.
        logging.debug('Grouping')
        # Group path aliases so that functions defined in headers will be sorted
        # by their actual size rather than shown as many small symbols.
        # Grouping these is nice since adding or remove just one path alias changes
        # the PSS of all symbols (a lot of noise).
        syms = syms.GroupedByAliases(same_name_only=True)
        logging.debug('Sorting')
        ret.symbols = syms.Sorted()
    logging.debug('Diff complete')
    return ret
コード例 #2
0
def Diff(before, after):
    """Diffs two SizeInfo objects. Returns a DeltaSizeInfo."""
    assert isinstance(before, models.SizeInfo)
    assert isinstance(after, models.SizeInfo)
    section_sizes = {
        k: after.section_sizes.get(k, 0) - v
        for k, v in before.section_sizes.iteritems()
    }
    for k, v in after.section_sizes.iteritems():
        if k not in section_sizes:
            section_sizes[k] = v

    symbol_diff = _DiffSymbolGroups(before.raw_symbols, after.raw_symbols)
    return models.DeltaSizeInfo(before, after, section_sizes, symbol_diff)