-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot-x-dmalen-16b-interval.py
More file actions
executable file
·101 lines (77 loc) · 2.81 KB
/
plot-x-dmalen-16b-interval.py
File metadata and controls
executable file
·101 lines (77 loc) · 2.81 KB
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
#!/usr/bin/env python
import argparse
import matplotlib.pyplot as plt
import matplotlib
from myplotlib import get_marker, get_color, change_aspect_ratio
from tlpperfparser import parse
ratio = 1.5
fontsize = 22
lfontsize = 16
markersize = 14
linewidth = 2.4
lines = { "linewidth" : linewidth,
"markersize" : markersize,
"markeredgewidth" : linewidth, }
markers = { "fillstyle" : "none", }
plt.rc("lines", **lines)
plt.rc("markers", **markers)
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['ps.fonttype'] = 42
def main():
round_map = {
"G": 1000000000,
"M": 1000000,
"K": 1000,
}
parser = argparse.ArgumentParser()
parser.add_argument("-u", "--unit", help = "unit of bandwidth",
choices = ["bps", "tps"], default = "bps")
parser.add_argument("-p", "--pattern", help = "access pattern",
choices = ["seq", "seq512", "fix", "random"],
default = "seq")
parser.add_argument("-r", "--round", help = "round up x axis",
choices = round_map.keys(),
default = list(round_map.keys())[0])
parser.add_argument("-R", "--ratio", help = "aspect ratio",
type = float, default = ratio)
parser.add_argument("-o", "--output", help = "output pdf file name",
default = None)
args = parser.parse_args()
dma_lens = list(map(lambda x: x * 16, range(129)))
dma_lens[0] = 1
xaxis = list(map(lambda x: x * 512, range(5)))
xaxis[0] = 1
if not args.output:
pdffile = ("graph/graph_x-dmalen-16binterval_" +
"pattern-{}_{}.pdf".format(args.pattern, args.unit))
else:
pdffile = args.output
fig, ax= plt.subplots()
bpses = []
tpses = []
for dma_len in dma_lens:
f = ("output-16b/read_pattern-{}_".format(args.pattern) +
"dmalen-{}_".format(dma_len) +
"cpu-16.txt")
bps, tps = parse(f)
bpses.append(bps)
tpses.append(tps)
if args.unit == "bps":
yaxis = bpses
elif args.unit == "tps":
yaxis = tpses
# round up to K, M, or G
yaxis = list(map(lambda x: x / round_map[args.round], yaxis))
ax.plot(dma_lens, yaxis, color = get_color())
plt.yticks([0, 1, 2, 3, 4])
plt.xticks(xaxis)
ax.tick_params(labelsize = fontsize)
ax.set_ylabel("throughput ({}{})".format(args.round, args.unit),
fontsize = fontsize)
ax.set_xlabel("request size (byte)", fontsize = fontsize)
ax.grid(True, linestyle = "--", linewidth = 0.5)
change_aspect_ratio(ax, args.ratio)
print("save '{}'".format(pdffile))
plt.savefig(pdffile, bbox_inches = "tight", pad_inches = 0.05)
if __name__ == "__main__":
main()