]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/usr/bin/env python |
2 | from collections import namedtuple | |
3 | from itertools import islice | |
4 | import operator | |
5 | import sys | |
6 | ||
7 | total_samples = 0 | |
8 | thread_module_samples = {} | |
9 | function_module_samples = {} | |
10 | module_samples = {} | |
11 | threads = set() | |
12 | ||
13 | ThreadModule = namedtuple('ThreadModule', ['thread', 'module']) | |
14 | FunctionModule = namedtuple('FunctionModule', ['function', 'module']) | |
15 | ||
16 | with open(sys.argv[1] + "/" + sys.argv[2] + ".perf.txt") as f: | |
17 | for line in f: | |
18 | fields = line.split() | |
19 | total_samples += int(fields[1]) | |
20 | key = ThreadModule(fields[2], fields[3]) | |
21 | thread_module_samples.setdefault(key, 0) | |
22 | thread_module_samples[key] += int(fields[1]) | |
23 | key = FunctionModule(fields[5], fields[3]) | |
24 | function_module_samples.setdefault(key, 0) | |
25 | function_module_samples[key] += int(fields[1]) | |
26 | threads.add(fields[2]) | |
27 | ||
28 | key = fields[3] | |
29 | module_samples.setdefault(key, 0) | |
30 | module_samples[key] += int(fields[1]) | |
31 | ||
32 | for thread in sorted(threads): | |
33 | thread_pct = 0 | |
34 | ||
35 | print("Thread: {:s}".format(thread)) | |
36 | print(" Percent Module") | |
37 | print("============================") | |
38 | for key, value in sorted(thread_module_samples.items(), key=operator.itemgetter(1), reverse=True): | |
39 | if key.thread == thread: | |
40 | print("{:8.4f} {:20s}".format(float(value) * 100 / total_samples, key.module)) | |
41 | thread_pct += float(value) * 100 / total_samples | |
42 | print("============================") | |
43 | print("{:8.4f} Total".format(thread_pct)) | |
44 | ||
45 | ||
46 | print(" Percent Module Function") | |
47 | print("=================================================================") | |
48 | for key, value in islice(sorted(function_module_samples.items(), key=operator.itemgetter(1), reverse=True), 100): | |
49 | print("{:8.4f} {:20s} {:s}".format(float(value) * 100 / total_samples, key.module, key.function)) | |
50 | ||
51 | ||
52 | ||
53 | print(" Percent Module") | |
54 | print("=================================") | |
55 | for key, value in sorted(module_samples.items(), key=operator.itemgetter(1), reverse=True): | |
56 | print("{:8.4f} {:s}".format(float(value) * 100 / total_samples, key)) | |
57 | ||
58 | ||
59 | with open(sys.argv[1] + "/" + sys.argv[2] + "_db_bench.txt") as f: | |
60 | for line in f: | |
61 | if "maxresident" in line: | |
62 | fields = line.split() | |
63 | print("Wall time elapsed: {:s}".format(fields[2].split("e")[0])) | |
64 | print("CPU utilization: {:s}".format(fields[3].split('C')[0])) | |
65 | user = float(fields[0].split('u')[0]) | |
66 | system = float(fields[1].split('s')[0]) | |
67 | print("User: {:8.2f} ({:5.2f}%)".format(user, user * 100 / (user + system))) | |
68 | print("System: {:8.2f} ({:5.2f}%)".format(system, system * 100 / (user + system))) | |
69 | ||
70 |