def METHOD_NAME(tmpdir, sort, *args):
    valid_sorts = pstats.Stats.sort_arg_dict_default
    if sort not in valid_sorts:
        sys.stderr.write('Invalid sort %r, must be one of %s\n' %
                         (sort, ', '.join(sorted(valid_sorts))))
        sys.exit(1)
    outfile = os.path.join(tmpdir, 'combined')
    do_record(tmpdir, outfile, *args)
    aggs = ('app.main', 'mitogen.broker', 'mitogen.child_main',
            'mitogen.service.pool', 'Strategy', 'WorkerProcess',
            'all')
    for agg in aggs:
        path = '%s-%s.pstat' % (outfile, agg)
        if os.path.exists(path):
            print()
            print()
            print('------ Aggregation %r ------' % (agg,))
            print()
            do_report(tmpdir, path, sort)
            print()