forked from sslab-gatech/vbench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph
executable file
·186 lines (158 loc) · 7 KB
/
graph
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/usr/bin/env python2
from mparts.analyze import *
import mparts.table as table
import mparts.graph as graph
import sys, os
import optparse
SCALE = {"MakeKernel" : (("hour", 60*60), ("secs", 1)),
"GmakeLoad" : (("hour", 60*60), ("secs", 1)),
"GmakeDockerLoad" : (("hour", 60*60), ("secs", 1)),
"GmakeFakerootLoad" : (("hour", 60*60), ("secs", 1)),
"GmakeQemuLoad" : (("hour", 60*60), ("secs", 1)),
"Smtpbm" : (("sec", 1), ("microsecs", 1000*1000)),
"EximLoad" : (("sec", 1), ("microsecs", 1000*1000)),
"EximQemuLoad" : (("sec", 1), ("microsecs", 1000*1000)),
"Mkdb" : (("hour", 60*60), ("secs", 1)),
"PsearchyLoad" : (("hour", 60*60), ("secs", 1)),
"PsearchyQemuLoad" : (("hour", 60*60), ("secs", 1)),
"Wrmem" : (("hour", 60*60), ("secs", 1)),
"MetisLoad" : (("hour", 60*60), ("secs", 1)),
"MetisQemuLoad" : (("hour", 60*60), ("secs", 1)),
"PGLoad" : (("sec", 1), ("microsecs", 1000*1000)),
"PostgresLoad" : (("sec", 1), ("microsecs", 1000*1000)),
"PostgresQemuLoad" : (("sec", 1), ("microsecs", 1000*1000)),
"MemcachedLoad" : (("sec", 1), ("microsecs", 1000*1000)),
"MemcachedQemuLoad" : (("sec", 1), ("microsecs", 1000*1000)),
}
def parseArgs(args):
usage = """\
Usage: %prog [options] dirs...
Recursively find all benchmark data point directories under the
directories given as arguments and graph those data points. Separate
benchmark types will be plotted in separate graphs."""
parser = optparse.OptionParser(usage = usage)
parser.add_option("-d", "--data", dest = "mode", action="store_const",
const = "data", default = "graph",
help = "emit only data tables")
parser.add_option("-p", "--strip", dest = "strip", type = "int",
default = 0, help = "strip NUM path elements from key",
metavar = "NUM")
for time in ["user", "sys", "idle"]:
parser.add_option("--no-" + time, action = "store_false",
dest = time, default = True,
help = "don't display %s time" % time)
def noTimes(option, opt, value, parser):
parser.values.user = parser.values.sys = parser.values.idle = False
parser.add_option("--no-times", action = "callback",
callback = noTimes,
help = "don't display any times")
parser.add_option("--y2-max", dest = "y2Max", type = "float",
default = None, help = "set upper limit of y2 to MAX",
metavar = "MAX")
if not len(args):
parser.error("Arguments expected")
return parser.parse_args(args)
def resultsTable(exps):
out = []
haveTimes = False
for exp in exps:
best = None
for rp in filterInfo(exp.info, className = "ResultsProvider"):
infoTup = (os.path.relpath(exp.path), rp["classNames"][0])
result = rp["result"]/rp["real"]
resultTup = (rp["cores"], result, rp["units"] + "/sec",
rp["real"])
if "time.real" in rp:
timesTup = (tuple(sum(rp.get("time." + name, 0)
for name in group) / rp["result"]
for group in
[["user", "nice"],
["sys", "irq", "softirq"],
["idle", "iowait"]]) +
(rp["unit"],))
haveTimes = True
else:
timesTup = ()
haveTimes = False
trial = infoTup + resultTup + timesTup
const = infoTup + (rp["cores"], rp["units"], haveTimes)
if best != None and best[2] != const:
raise ValueError(
"Trials disagree on constants:\n%r\n versus\n%r" %
(best[2], const))
if best == None or result > best[0]:
best = (result, trial, const)
if best == None:
raise ValueError("No ResultsProviders in %r" % exp)
out.append(best[1])
cols = ["path", "className", "cores", "result", "units", "real"]
if haveTimes:
cols.extend(["user", "sys", "idle", "timeUnits"])
desc = table.TableDesc(*cols)
return table.Table.fromIterable(out, desc)
opts, paths = parseArgs(sys.argv[1:])
graphs = {}
for name, exps in series(*paths):
name = name.split("/", opts.strip)[-1]
tab = resultsTable(exps)
fixed = the(tab.project("className", "units"))
if "user" in tab.desc:
tunits = the(tab.project("timeUnits")).timeUnits
rest = (("user/"+tunits, "user"), ("sys/"+tunits, "sys"),
("idle/"+tunits, "idle"))
else:
rest = ()
toShow = tab.project("path", #("path", lambda row: row.path.split("/", 2)[-1]),
"cores", (None, "className"),
(fixed.units, "result"), (None, "units"),
"real", *rest)
print "# %s" % name
print toShow.renderText()
print
print
if opts.mode == "data":
continue
scaleRes, scaleTime = SCALE.get(fixed.className, (("sec", 1), ("secs", 1)))
g, idx = graphs.get(fixed.className, (None, 0))
if not g:
g = graph.Gnuplot(pdf="%s.pdf" % fixed.className, archive=True)
g.title = fixed.className
g.xlabel = "cores"
g.ylabel = fixed.units.replace("/sec", "/%s" % scaleRes[0])
g.yrange = "[0:*]"
if "user" in tab.desc and (opts.user or opts.sys or opts.idle):
g.y2label = "CPU time (%s/%s)" % (scaleTime[0], tunits)
g.y2tics = ""
if opts.y2Max != None:
g.y2range = "[0:%g]" % opts.y2Max
g.ytics = "nomirror"
# # Differential curve
# pres = pcores = 0
# curve = []
# for (cores, res) in tab.project("cores", "result"):
# res *= cores
# curve.append((cores, (res - pres) / (cores - pcores)))
# pres, pcores = res, cores
# # Total throughput curve
# curve = []
# for (cores, res) in tab.project("cores", "result"):
# curve.append((cores, res * cores))
# Per-core throughput curve
projRes = lambda row: row.result * scaleRes[1]
curve = tab.project("cores", ("result", projRes))
color = 1
g.addData(curve, with_ = "lines", title = name, linecolor = color)
if "user" in tab.desc:
for n, t in [(6, "user"), # Circle for wx terminal
(8, "sys"), # Triangle
(2, "idle")]: # Cross
if not getattr(opts, t):
continue
projTime = lambda row: getattr(row, t) * scaleTime[1]
color += 1
g.addData(tab.project("cores", (t, projTime)), axis = "x1y2",
with_ = "linespoints", title = name + " " + t,
linecolor = color, pointtype = n)
graphs[fixed.className] = (g, idx+1)
for g, _ in graphs.itervalues():
g.plot()