def main(argv): status = 0 try: config = Config().init(CONFIG) config.argparse.add_argument('inputs', metavar='FILE', nargs=2) config.parse(argv) config['args.fill_holes'] = False inputs = config.get('args.inputs') a_dfs = memdf.collect.collect_files(config, files=[inputs[0]]) b_dfs = memdf.collect.collect_files(config, files=[inputs[1]]) a_syms = a_dfs[SymbolDF.name].sort_values(by='symbol', ignore_index=True) b_syms = b_dfs[SymbolDF.name].sort_values(by='symbol', ignore_index=True) # TBD: Differences other than size, configurably. differences = [] ai = a_syms.itertuples() bi = b_syms.itertuples() a = next(ai, None) b = next(bi, None) while a and b: if a.symbol < b.symbol: differences.append((-a.size, a.size, 0, a.symbol)) a = next(ai, None) continue if a.symbol > b.symbol: differences.append((b.size, 0, b.size, b.symbol)) b = next(bi, None) continue if a.size != b.size: differences.append((b.size - a.size, a.size, b.size, a.symbol)) a = next(ai, None) b = next(bi, None) for a in ai: differences.append((-a.size, a.size, 0, a.symbol)) for b in bi: differences.append((b.size, 0, b.size, b.symbol)) df = pd.DataFrame(differences, columns=['change', 'a-size', 'b-size', 'symbol']) if config['report.demangle']: # Demangle early to sort by demangled name. df['symbol'] = df['symbol'].apply(memdf.report.demangle) config['report.demangle'] = False df.sort_values(by=['change', 'symbol'], ascending=[False, True], inplace=True) memdf.report.write_dfs(config, {'Differences': df}) except Exception as exception: status = 1 raise exception return status
def postprocess_config(config: Config, _key: str, _info: Mapping) -> None: """Postprocess --github-repository.""" if config['github.repository']: owner, repo = config.get('github.repository').split('/', 1) config.put('github.owner', owner) config.put('github.repo', repo) if not config['github.token']: config['github.token'] = os.environ.get('GITHUB_TOKEN') if not config['github.token']: logging.error('Missing --github-token')
def postprocess_output_metadata(config: Config, key: str) -> None: """For --output-metadata=KEY:VALUE list, convert to dictionary.""" assert key == 'output.metadata' metadata = {} for s in config.get(key): if ':' in s: k, v = s.split(':', 1) else: k, v = s, True metadata[k] = v config.put(key, metadata)
def main(argv): status = 0 try: config = Config().init(CONFIG) config.argparse.add_argument('inputs', metavar='FILE', nargs=2) config.parse(argv) config['args.fill_holes'] = False inputs = config.get('args.inputs') a_dfs = memdf.collect.collect_files(config, files=[inputs[0]]) b_dfs = memdf.collect.collect_files(config, files=[inputs[1]]) a_syms = a_dfs[SymbolDF.name].sort_values(by='symbol') b_syms = b_dfs[SymbolDF.name].sort_values(by='symbol') # TBD: Differences other than size, configurably. differences = [] ai = a_syms.itertuples() bi = b_syms.itertuples() while True: if (a := next(ai, None)) is None: break if (b := next(bi, None)) is None: differences.append((a.symbol, a.size, None)) break if a.symbol < b.symbol: differences.append((a.symbol, a.size, None)) a = next(ai, None) continue if a.symbol > b.symbol: differences.append((b.symbol, None, b.size)) b = next(bi, None) continue if a.size != b.size: differences.append((a.symbol, a.size, b.size))
def postprocess_report_by(config: Config, key: str, info: Mapping) -> None: """For --report-by=region, select all sections.""" assert key == 'report.by' if config.get(key) == 'region': config.put('section.select-all', True),