def main(args=None):
    if args is None:
        args = sys.argv

    parser = argparse.ArgumentParser(
        fromfile_prefix_chars='@',
        description=
        """Create CSV tables for quantile plots with the results of a benchmark execution.
           The CSV tables are similar to those produced with table-generator,
           but have an additional first column with the index for the quantile plot,
           and they are sorted.
           The output is written to stdout.
           Part of BenchExec: https://github.com/sosy-lab/benchexec/"""
    )

    parser.add_argument("result",
        metavar="RESULT",
        type=str,
        help="XML file with result produced by benchexec"
    )
    parser.add_argument("--correct-only",
        action="store_true", dest="correct_only",
        help="only use correct results (recommended, implied if --score-based is used)"
    )
    parser.add_argument("--score-based",
        action="store_true", dest="score_based",
        help="create data for score-based quantile plot"
    )

    options = parser.parse_args(args[1:])

    # load results
    run_set_result = tablegenerator.RunSetResult.create_from_xml(
            options.result, tablegenerator.parse_results_file(options.result))
    run_set_result.collect_data(options.correct_only)

    # select appropriate results
    if options.score_based:
        start_index = 0
        index_increment = lambda run_result: run_result.score
        results = []
        for run_result in run_set_result.results:
            if run_result.score is None:
                sys.exit('No score available for task {0}, '
                         'cannot produce score-based quantile data.'
                         .format(run_result.task_id[0]))

            if run_result.category == result.CATEGORY_WRONG:
                start_index += run_result.score
            elif run_result.category == result.CATEGORY_MISSING:
                sys.exit('Property missing for task {0}, '
                         'cannot produce score-based quantile data.'
                         .format(run_result.task_id[0]))
            elif run_result.category == result.CATEGORY_CORRECT:
                results.append(run_result)
            else:
                assert run_result.category in {result.CATEGORY_ERROR, result.CATEGORY_UNKNOWN}
    else:
        start_index = 0
        index_increment = lambda run_result: 1
        if options.correct_only:
            results = [run_result for run_result in run_set_result.results
                       if run_result.category == result.CATEGORY_CORRECT]
        else:
            results = run_set_result.results

    # sort data for quantile plot
    results.sort(key=extract_cputime)

    # extract information which id columns should be shown
    for run_result in run_set_result.results:
        run_result.id = run_result.task_id
    relevant_id_columns = tablegenerator.select_relevant_id_columns(results)

    # write output
    index = start_index
    for run_result in results:
        index += index_increment(run_result)
        columns = itertools.chain(
                [index],
                (id for id, show in zip(run_result.id, relevant_id_columns) if show),
                map(Util.remove_unit, (value or '' for value in run_result.values)),
                )
        print(*columns, sep='\t')
dataset/ETHPy150Open sosy-lab/benchexec/contrib/plots/quantile-generator.py/main/original