From 1bec2470a77e893b2022b508afa09f1a73fcdb39 Mon Sep 17 00:00:00 2001 From: Christopher Kenna Date: Sat, 15 Oct 2011 04:36:47 -0400 Subject: beta experiment plotting scripts --- plot_rtas12_betaexp.py | 118 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100755 plot_rtas12_betaexp.py (limited to 'plot_rtas12_betaexp.py') 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 @@ +#!/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.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) + 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() -- cgit v1.2.2