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
|
#!/usr/bin/env python
import sys
import optparse
from plot import Plot
from gnuplot import curve
COLS = {'beta-mean': 0,
'rel-rt-max-b': 1,
'rel-rt-mean-b': 2,
'misses-b': 3,
'new-misses-b': 4,
'rel-rt-max-c': 5,
'rel-rt-mean-c': 6,
'misses-c': 7,
'new-misses-c': 8,
'mean-misses-c': 9,
'miss-ratio-b': 10,
'miss-ratio-c': 11}
def parse_args():
p = optparse.OptionParser(description='make graphs')
p.add_option('--paper', dest='paper', action='store_true', default=False)
return p.parse_args()
def col(key):
"""Get the column in the data set."""
return COLS[key]
def g_col(key):
"""Gnuplot is 1-indexed."""
return 1 + col(key)
def get_y_label(metric):
LABELS = {'rel-rt-max': 'relative response time maximum',
'rel-rt-mean': 'relative response time mean',
'miss-ratio': 'deadline miss ratio'}
return LABELS[metric]
def set_plot_opts(p):
p.rounded_caps = True
p.font = 'Helvetica'
p.font_size = '5pt'
p.size = ('8.5cm', '5.25cm')
p.default_style = 'linespoints lw 2.5'
p.default_style += ' smooth bezier'
p.monochrome = False
p.ylog = True
p.key = 'off'
p.line_styles = [(1, "lw 1.5 ps 0.4"),
(2, "lw 1.5 ps 0.4"),
(3, "lw 1.5 ps 0.4"),
(4, "lw 1.5 ps 0.4")]
for i, c in enumerate(p.curves):
c.style = "linespoints ls %d" % (i + 1)
def plot_metric(opts, dat_dir, metric, coin_prob, xr=None):
"""Plot metric for each level, enforcement pair at the specified
probability.
."""
# each coin value gets a plot
p = Plot()
p.output = '{0}/beta-exp_metric={1}_prob={2}'.format(dat_dir, metric, coin_prob)
if xr is not None:
p.output = '{0}_zoom=1'.format(p.output)
p.output = '{0}.pdf'.format(p.output)
p.format = 'pdf'
for (level, enforcement) in [(l, e) for l in ('b', 'c') for e in (0, 1)]:
fname = '{0}/beta_be={1}_prob={2}.csv'.format(dat_dir, enforcement, coin_prob)
ycol = g_col('{0}-{1}'.format(metric, level))
if enforcement == 1:
ti ='{0} {1}'.format(level.upper(), 'enforcement')
else:
ti ='{0} {1}'.format(level.upper(), 'no enforcement')
c = curve(fname=fname, xcol=g_col('beta-mean'), ycol=ycol, title=ti)
p.curves += [c]
p.xlabel = 'beta mean with probability {0}'.format(coin_prob)
p.ylabel = get_y_label(metric)
set_plot_opts(p)
if xr is not None:
p.xrange = xr
# special formatting cases
if -1 != metric.find('ratio'):
p.ylog = False
p.yrange = (-0.01, 1.01)
if metric == 'miss-ratio' and coin_prob == 0.1:
p.key = 'top right'
p.gnuplot_exec()
def main():
opts, files = parse_args()
if len(files) < 1:
print >>sys.stderr, "missing directory"
sys.exit(1)
data_dir = files[0]
COIN_VALS = [0.1, 0.5]
for coin_val in COIN_VALS:
plot_metric(opts, data_dir, 'rel-rt-mean', coin_val)
plot_metric(opts, data_dir, 'rel-rt-mean', coin_val, xr=(0.02, 0.11))
plot_metric(opts, data_dir, 'miss-ratio', coin_val)
# not in paper
plot_metric(opts, data_dir, 'rel-rt-max', coin_val)
if __name__ == '__main__':
main()
|