diff options
| author | Christopher Kenna <cjk@cs.unc.edu> | 2011-10-15 04:36:47 -0400 |
|---|---|---|
| committer | Christopher Kenna <cjk@cs.unc.edu> | 2011-10-15 04:36:47 -0400 |
| commit | 1bec2470a77e893b2022b508afa09f1a73fcdb39 (patch) | |
| tree | 5614a158313a94360444a4440107e86b2b216f3d | |
| parent | ee994acc67a6d6a67d8413f7c1724cbae3d3ea41 (diff) | |
beta experiment plotting scripts
| -rwxr-xr-x | plot_rtas12_betaexp.py | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/plot_rtas12_betaexp.py b/plot_rtas12_betaexp.py new file mode 100755 index 0000000..31846f4 --- /dev/null +++ b/plot_rtas12_betaexp.py | |||
| @@ -0,0 +1,118 @@ | |||
| 1 | #!/usr/bin/env python | ||
| 2 | |||
| 3 | import sys | ||
| 4 | import optparse | ||
| 5 | |||
| 6 | from plot import Plot | ||
| 7 | from gnuplot import curve | ||
| 8 | |||
| 9 | COLS = {'beta-mean': 0, | ||
| 10 | 'rel-rt-max-b': 1, | ||
| 11 | 'rel-rt-mean-b': 2, | ||
| 12 | 'misses-b': 3, | ||
| 13 | 'new-misses-b': 4, | ||
| 14 | 'rel-rt-max-c': 5, | ||
| 15 | 'rel-rt-mean-c': 6, | ||
| 16 | 'misses-c': 7, | ||
| 17 | 'new-misses-c': 8, | ||
| 18 | 'mean-misses-c': 9, | ||
| 19 | 'miss-ratio-b': 10, | ||
| 20 | 'miss-ratio-c': 11} | ||
| 21 | |||
| 22 | |||
| 23 | def parse_args(): | ||
| 24 | p = optparse.OptionParser(description='make graphs') | ||
| 25 | p.add_option('--paper', dest='paper', action='store_true', default=False) | ||
| 26 | return p.parse_args() | ||
| 27 | |||
| 28 | |||
| 29 | def col(key): | ||
| 30 | """Get the column in the data set.""" | ||
| 31 | return COLS[key] | ||
| 32 | |||
| 33 | |||
| 34 | def g_col(key): | ||
| 35 | """Gnuplot is 1-indexed.""" | ||
| 36 | return 1 + col(key) | ||
| 37 | |||
| 38 | |||
| 39 | def get_y_label(metric): | ||
| 40 | LABELS = {'rel-rt-max': 'relative response time maximum', | ||
| 41 | 'rel-rt-mean': 'relative response time mean', | ||
| 42 | 'miss-ratio': 'deadline miss ratio'} | ||
| 43 | return LABELS[metric] | ||
| 44 | |||
| 45 | |||
| 46 | def set_plot_opts(p): | ||
| 47 | p.rounded_caps = True | ||
| 48 | p.font = 'Helvetica' | ||
| 49 | p.font_size = '5pt' | ||
| 50 | p.size = ('8.5cm', '5.25cm') | ||
| 51 | p.default_style = 'linespoints lw 2.5' | ||
| 52 | p.default_style += ' smooth bezier' | ||
| 53 | p.monochrome = False | ||
| 54 | p.ylog = True | ||
| 55 | |||
| 56 | p.line_styles = [(1, "lw 1.5 ps 0.4"), | ||
| 57 | (2, "lw 1.5 ps 0.4"), | ||
| 58 | (3, "lw 1.5 ps 0.4"), | ||
| 59 | (4, "lw 1.5 ps 0.4")] | ||
| 60 | for i, c in enumerate(p.curves): | ||
| 61 | c.style = "linespoints ls %d" % (i + 1) | ||
| 62 | |||
| 63 | |||
| 64 | def plot_metric(opts, dat_dir, metric, coin_prob, xr=None): | ||
| 65 | """Plot metric for each level, enforcement pair at the specified | ||
| 66 | probability. | ||
| 67 | |||
| 68 | .""" | ||
| 69 | # each coin value gets a plot | ||
| 70 | p = Plot() | ||
| 71 | p.output = '{0}/beta-exp_metric={1}_prob={2}'.format(dat_dir, metric, coin_prob) | ||
| 72 | if xr is not None: | ||
| 73 | p.output = '{0}_zoom=1'.format(p.output) | ||
| 74 | p.output = '{0}.pdf'.format(p.output) | ||
| 75 | |||
| 76 | p.format = 'pdf' | ||
| 77 | |||
| 78 | for (level, enforcement) in [(l, e) for l in ('b', 'c') for e in (0, 1)]: | ||
| 79 | fname = '{0}/beta_be={1}_prob={2}.csv'.format(dat_dir, enforcement, coin_prob) | ||
| 80 | ycol = g_col('{0}-{1}'.format(metric, level)) | ||
| 81 | if enforcement == 1: | ||
| 82 | ti ='{0} {1}'.format(level.upper(), 'enforcement') | ||
| 83 | else: | ||
| 84 | ti ='{0} {1}'.format(level.upper(), 'no enforcement') | ||
| 85 | c = curve(fname=fname, xcol=g_col('beta-mean'), ycol=ycol, title=ti) | ||
| 86 | p.curves += [c] | ||
| 87 | p.xlabel = 'beta mean with probability {0}'.format(coin_prob) | ||
| 88 | p.ylabel = get_y_label(metric) | ||
| 89 | set_plot_opts(p) | ||
| 90 | if xr is not None: | ||
| 91 | p.xrange = xr | ||
| 92 | |||
| 93 | # special formatting cases | ||
| 94 | if -1 != metric.find('ratio'): | ||
| 95 | p.ylog = False | ||
| 96 | p.yrange = (-0.01, 1.01) | ||
| 97 | p.gnuplot_exec() | ||
| 98 | |||
| 99 | def main(): | ||
| 100 | |||
| 101 | opts, files = parse_args() | ||
| 102 | |||
| 103 | if len(files) < 1: | ||
| 104 | print >>sys.stderr, "missing directory" | ||
| 105 | sys.exit(1) | ||
| 106 | |||
| 107 | data_dir = files[0] | ||
| 108 | |||
| 109 | COIN_VALS = [0.1, 0.5] | ||
| 110 | for coin_val in COIN_VALS: | ||
| 111 | plot_metric(opts, data_dir, 'rel-rt-mean', coin_val) | ||
| 112 | plot_metric(opts, data_dir, 'rel-rt-mean', coin_val, xr=(0.02, 0.11)) | ||
| 113 | plot_metric(opts, data_dir, 'miss-ratio', coin_val) | ||
| 114 | # not in paper | ||
| 115 | plot_metric(opts, data_dir, 'rel-rt-max', coin_val) | ||
| 116 | |||
| 117 | if __name__ == '__main__': | ||
| 118 | main() | ||
