forked from nitsanw/javanetperf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bytebuffer_plot.py
85 lines (68 loc) · 2.4 KB
/
bytebuffer_plot.py
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
#!/usr/bin/python
import sys
import dataextract
import stupidplot
LABEL_MAP = {
"array": "byte[]",
"heap": "ByteBuffer heap",
"direct": "ByteBuffer direct",
"be": "Big Endian",
"le": "Little Endian",
}
def labelCmp(a, b):
print a, b, LABEL_MAP[a[0]] < LABEL_MAP[b[0]]
v = cmp(LABEL_MAP[a[0]], LABEL_MAP[b[0]])
if v != 0:
return v
return cmp(a[1], b[1])
def plot(path):
table = dataextract.readCSVTable(path)
# Take only the little endian results
#~ table = dataextract.select(table, [(1, "le")])
# Express buffer size in kB
table = [(r[0], r[1], r[2]/1024, r[3]) for r in table]
# Express throughput in GB/s
#~ table = [(r[0], r[1], r[2], r[3]/1024.) for r in table]
groups = dataextract.groupBy(table, [0, 1])
datasets = []
keys = groups.keys()
keys.sort(labelCmp)
for key in keys:
data = dataextract.selectStatsConfPlot(groups[key], [2], 3)
label = ("Buffer Size (kB)", "%s %s" % (LABEL_MAP[key[0]], LABEL_MAP[key[1]]))
#~ label = ("Buffer Size (kB)", LABEL_MAP[key[0]])
print label
data.insert(0, label)
datasets.append(data)
print data
#~ data = dataextract.selectStatsConfPlot(table, [0, 1, 2], 3)
#~ print data
options = {
"key": "bottom right",
"errorbars": [1],
"xrange": "[0:]",
"yrange": "[0:]",
#~ "ylabel": "Write Throughput (GB/s)",
#~ "ylabel": "Fill Byte Throughput (MB/s)",
"ylabel": "Fill Int Throughput (MB/s)",
"xformat": "%.0f",
#~ "xtics": "1024",
"yformat": "%.0f",
}
stupidplot.gnuplotTable(datasets, "out.eps", options)
#~ plot_datasets = []
#~ keys = groups.keys()
#~ keys.sort()
#~ for key in keys:
#~ print groups[key][0]
#~ data = dataextract.selectStatsConfPlot(groups[key], [0, 1, 2], 3)
#~ label = "%d CPUs" % key
#~ data.insert(0, [X_AXIS, label, "- conf", "+ conf"])
#~ datasets.append(data)
#~ stupidplot.gnuplotTable(datasets, path.replace(".csv", ".eps"), options)
#~ # For each number of threads, pick out the maximum
#~ max_table = [["CPUs", input_label]]
#~ for key in keys:
#~ data = dataextract.selectStatsConfPlot(groups[key], [1], 2)
if __name__ == "__main__":
plot(sys.argv[1])