From c8b2f1313326bee25e847bd7f979c0eb2bba2883 Mon Sep 17 00:00:00 2001 From: Christopher Kenna Date: Thu, 5 Jan 2012 21:32:02 -0500 Subject: Plotting with different level-curves on the graphs. --- plot_rtas12.py | 127 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 69 insertions(+), 58 deletions(-) diff --git a/plot_rtas12.py b/plot_rtas12.py index d5e9ed9..d65534e 100755 --- a/plot_rtas12.py +++ b/plot_rtas12.py @@ -50,26 +50,38 @@ def gnuplot_col(col_name): return 1 + COLS[col_name] def get_sched_title(sched): - SCHEDULERS = {'MC': 'Basic', - 'MC-MERGE': 'IM + TM', - 'MC-MERGE-REDIR': 'IM + TM + WR'} + SCHEDULERS = {'MC': 'Basic:', + 'MC-MERGE': 'IM + TM:', + 'MC-MERGE-REDIR': 'All:'} return SCHEDULERS[sched] def get_overhead_title(ov): - OV = {'SCHED': '(A, B, C)', - 'LVLA-SCHED': '(A)', - 'RELEASE': '(A, B, C)', - 'LVLA-RELEASE': '(A)'} + OV = {'LVLA-SCHED': 'A', + 'LVLB-SCHED': 'B', + 'LVLC-SCHED': 'C', + 'LVLA-RELEASE': 'A', + 'LVLB-RELEASE': 'B', + 'LVLC-RELEASE': 'C', +} return OV[ov] +def get_line_style(sched, o_type): + S = { 'MC' : {'LVLA': 1, 'LVLB': 4, 'LVLC': 7}, + 'MC-MERGE': {'LVLA': 2, 'LVLB': 5, 'LVLC': 8}, + 'MC-MERGE-REDIR': {'LVLA': 3, 'LVLB': 6, 'LVLC': 9}} + o = o_type.split('-')[0] + return 'linespoints linestyle {0}'.format(S[sched][o]) + +def get_graph_fname(directory, o_type, levels, ycol_type): + return '{0}/overhead={1}-levels={2}-type={3}'.format(directory, o_type, + levels, ycol_type) + def set_plot_opts(opts, p): p.rounded_caps = True p.font = 'Helvetica' - p.default_style = 'linespoints lw 2.5' - p.default_style += ' smooth bezier' p.key = 'off' p.monochrome = False - p.dashed_lines = False + p.dashed_lines = True p.xrange = (18, 122) p.yrange = (0, '') @@ -88,27 +100,18 @@ def set_plot_opts(opts, p): p.output = '{0}.{1}'.format(p.output, ext) p.format = ext - for i, c in enumerate(p.curves): - c.style = "linespoints ls %d" % (i + 1) - - try: - # don't use yellow if we have this curve - p.curves[5].style = "linespoints ls 7" - except IndexError: - pass - p.line_styles = [ - (1, "lw {0} ps {1}".format(line_width, point_size)), - (2, "lw {0} ps {1}".format(line_width, point_size)), - (3, "lw {0} ps {1}".format(line_width, point_size)), - (4, "lw {0} ps {1}".format(line_width, point_size)), - (5, 'pt 6 lw {0} ps {1} lc rgbcolor "#ff910d"'.format(line_width, point_size)), - (6, "pt 7 lw {0} ps {1}".format(line_width, point_size)), - (7, 'lw {0} ps {1} lc rgbcolor "#000000"'.format(line_width, point_size)), - (8, "lw {0} ps {1}".format(line_width, point_size)), + (1, 'lt 1 pt 1 lw {0} ps {1} lc rgbcolor "#ff0000"'.format(line_width, point_size)), + (2, 'lt 1 pt 4 lw {0} ps {1} lc rgbcolor "#00ff00"'.format(line_width, point_size)), + (3, 'lt 1 pt 7 lw {0} ps {1} lc rgbcolor "#0000ff"'.format(line_width, point_size)), + (4, 'lt 2 pt 1 lw {0} ps {1} lc rgbcolor "#ff0000"'.format(line_width, point_size)), + (5, 'lt 2 pt 4 lw {0} ps {1} lc rgbcolor "#00ff00"'.format(line_width, point_size)), + (6, 'lt 2 pt 7 lw {0} ps {1} lc rgbcolor "#0000ff"'.format(line_width, point_size)), + (7, 'lt 3 pt 1 lw {0} ps {1} lc rgbcolor "#ff0000"'.format(line_width, point_size)), + (8, 'lt 3 pt 4 lw {0} ps {1} lc rgbcolor "#00ff00"'.format(line_width, point_size)), + (9, 'lt 3 pt 7 lw {0} ps {1} lc rgbcolor "#0000ff"'.format(line_width, point_size)), ] - def get_data_matrix(fname): ret = [] with open(fname, 'r') as f: @@ -162,34 +165,36 @@ def include_level_a_releases(data_dir, o_type, scheduler, ycol): f.file.flush() return (f.name, f) +def add_key_to_plot(p): + p.key = 'on tmargin center horizontal maxcolumns 3' + p.size = ('8.5cm', '6.25cm') -def plot_release(opts, data_dir, ycol, title, fname): - p = Plot() - p.output = '{0}/{1}'.format(data_dir, fname) +def plot_release(opts, data_dir, ycol_name, title, levels): + levels = levels.upper() refs = [] # need to save reference to file handle so it is not deleted + p = Plot() + p.output = get_graph_fname(data_dir, 'RELEASE', levels, ycol_name) - for o_type in ['RELEASE', 'LVLA-RELEASE']: + for o_type in ['LVL{0}-RELEASE'.format(l) for l in levels]: for sched in SCHEDULERS: - if o_type == 'RELEASE': - # we have to make the regular release include the level-A - # releases - fname, ref = include_level_a_releases(data_dir, o_type, - sched, ycol) - refs.append(ref) - else: - fname = '{0}/scheduler={1}_overhead={2}.csv'.format(data_dir, sched, o_type) + # if o_type == 'RELEASE': + # # we have to make the regular release include the level-A + # # releases + # fname, ref = include_level_a_releases(data_dir, o_type, + # sched, ycol) + # refs.append(ref) + # else: + fname = '{0}/scheduler={1}_overhead={2}.csv'.format(data_dir, sched, o_type) ti = '{0} {1}'.format(get_sched_title(sched), get_overhead_title(o_type)) - p.curves += [curve(fname=fname, xcol=gnuplot_col('n_tasks'), - ycol=ycol, title=ti)] + c = curve(fname=fname, xcol=gnuplot_col('n_tasks'), + ycol=gnuplot_col(ycol_name), title=ti, + style=get_line_style(sched, o_type)) + p.curves += [c] p.xlabel = 'number of tasks' p.ylabel = 'overhead (microseconds)' set_plot_opts(opts, p) - if gnuplot_col('avg') == ycol: - # make this graph's y-scale match the scale on the average-case - # scheduling overhead graph because they are next to each other - p.yrange = (0, 16) - # it gets the key - p.key = 'top left' + if 'avg' == ycol_name and 'ABC' == levels: + add_key_to_plot(p) p.gnuplot_exec() def plot_release_jim(opts, data_dir, ycol, title, fname): @@ -210,19 +215,24 @@ def plot_release_jim(opts, data_dir, ycol, title, fname): p.title = 'level-A worst-case release overhead' p.gnuplot_exec() -def plot_sched(opts, data_dir, ycol, title, fname): +def plot_sched(opts, data_dir, ycol_name, title, levels): + levels = levels.upper() p = Plot() - p.output = '{0}/{1}'.format(data_dir, fname) + p.output = get_graph_fname(data_dir, 'SCHED', levels, ycol_name) - for o_type in ['SCHED', 'LVLA-SCHED']: + for o_type in ['LVL{0}-SCHED'.format(l) for l in levels]: for sched in SCHEDULERS: fname = '{0}/scheduler={1}_overhead={2}.csv'.format(data_dir, sched, o_type) ti = '{0} {1}'.format(get_sched_title(sched), get_overhead_title(o_type)) - p.curves += [curve(fname=fname, xcol=gnuplot_col('n_tasks'), - ycol=ycol, title=ti)] + c = curve(fname=fname, xcol=gnuplot_col('n_tasks'), + ycol=gnuplot_col(ycol_name), title=ti, + style=get_line_style(sched, o_type)) + p.curves += [c] p.xlabel = 'number of tasks' p.ylabel = 'overhead (microseconds)' set_plot_opts(opts, p) + if 'avg' == ycol_name and 'ABC' == levels: + add_key_to_plot(p) p.gnuplot_exec() @@ -234,11 +244,12 @@ def main(): usage('missing args') data_dir = extra[0] - plot_sched(opts, data_dir, gnuplot_col('max'), 'worst-case scheduling overhead', 'overhead=SCHED_type=MAX') - plot_release(opts, data_dir, gnuplot_col('max'), 'worst-case release overhead', 'overhead=RELEASE_type=MAX') - plot_sched(opts, data_dir, gnuplot_col('avg'), 'average-case scheduling overhead', 'overhead=SCHED_type=AVG') - plot_release(opts, data_dir, gnuplot_col('avg'), 'average-case release overhead', 'overhead=RELEASE_type=AVG') - plot_release_jim(opts, data_dir, gnuplot_col('max'), 'worst-case release overhead', 'overhead=RELEASE_type=MAX_for-jim=1') + for levels in ('ABC', 'AC', 'BC'): + plot_sched(opts, data_dir, 'max', 'worst-case scheduling overhead', levels) + plot_release(opts, data_dir, 'max', 'worst-case release overhead', levels) + plot_sched(opts, data_dir, 'avg', 'average-case scheduling overhead', levels) + plot_release(opts, data_dir, 'avg', 'average-case release overhead', levels) + #plot_release_jim(opts, data_dir, 'max', 'worst-case release overhead', 'overhead=RELEASE_type=MAX_for-jim=1') if __name__ == '__main__': main() -- cgit v1.2.2