def analyze_benchmark_results(benchmark_result, benchmark):
output = BenchmarkResult()<EOL>output.name = benchmark_result.name<EOL>output.group = benchmark_result.group<EOL>output.failures = benchmark_result.failures<EOL>raw_results = benchmark_result.results<EOL>temp = dict()<EOL>for metric in benchmark.raw_metrics:<EOL><INDENT>temp[metric] = raw_results[metric]<EOL><DEDENT>output.results = temp<EOL>aggregate_results = list()<EOL>for metricname, aggregate_list in benchmark.aggregated_metrics.items():<EOL><INDENT>numbers = raw_results[metricname]<EOL>for aggregate_name in aggregate_list:<EOL><INDENT>if numbers:  <EOL><INDENT>aggregate_function = AGGREGATES[aggregate_name]<EOL>aggregate_results.append(<EOL>(metricname, aggregate_name, aggregate_function(numbers)))<EOL><DEDENT>else:<EOL><INDENT>aggregate_results.append((metricname, aggregate_name, None))<EOL><DEDENT><DEDENT><DEDENT>output.aggregates = aggregate_results<EOL>return output<EOL>
Take a benchmark result containing raw benchmark results, and do aggregation by
    applying functions

    Aggregates come out in format of metricname, aggregate_name, result