1#!/usr/bin/python2
2from __future__ import absolute_import
3from __future__ import division
4from __future__ import print_function
5
6import os
7import re
8import sys
9
10
11def avg_deviation(values):
12    sum = 0
13    count = 0
14
15    if not values:
16        return (0, 0)
17    for x in values:
18        sum += x
19        count += 1
20    average = sum / count
21    sum_sq_dev = 0
22    for x in values:
23        sum_sq_dev += (x - average) ** 2
24    std_dev = (sum_sq_dev / count)**0.5
25    return (average, 100 * std_dev / average)
26
27
28list = []
29for line in sys.stdin.readlines():
30    (user, system, elapsed, cpu) = line.split()[0:4]
31    user = float(re.match(r'([\d\.]+)', user).group(0))
32    system = float(re.match(r'([\d\.]+)', system).group(0))
33    m = re.match(r'(\d+):([\d\.]+)', elapsed)
34    elapsed = 60*int(m.group(1)) + float(m.group(2))
35    cpu = int(re.match(r'(\d+)', cpu).group(0))
36
37    list.append((user, system, elapsed, cpu))
38
39print("   user: %0.2fs (%0.2f%%)" % avg_deviation([x[0] for x in list]))
40print(" system: %0.2fs (%0.2f%%)" % avg_deviation([x[1] for x in list]))
41print("elapsed: %0.2fs (%0.2f%%)" % avg_deviation([x[2] for x in list]))
42print("    cpu: %d%% (%0.2f%%)" % avg_deviation([x[3] for x in list]))
43