From fa1fb842fe42e07508cc8f6cf371aeb468b077a3 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Fri, 2 Apr 2010 15:26:30 -0400 Subject: Better file processing in plot_pm and plotting errorbars --- gnuplot.py | 11 ++++- plot_pm.py | 159 ++++++++++++++++++++++++------------------------------------- 2 files changed, 72 insertions(+), 98 deletions(-) diff --git a/gnuplot.py b/gnuplot.py index d32b3c5..0afb9b3 100755 --- a/gnuplot.py +++ b/gnuplot.py @@ -56,8 +56,15 @@ def gnuplot_cmd(graphs, title=None, ylabel=None, xlabel=None, g('set key %s' % key) plot = [] for gr in graphs: - par = (gr[0], gr[1], gr[2], gr[3], style) if len(gr) == 4 else gr - plot += ["'%s' using %s:%s title '%s' with %s" % par] + if len(gr) == 4: + par = (gr[0], gr[1], gr[2], gr[3], style) + plot += ["'%s' using %s:%s title '%s' with %s" % par] + elif len(gr) == 6: + par = (gr[0], gr[1], gr[2], gr[3], gr[4], style, gr[5]) + plot += ["'%s' using %s:%s:%s:%s with %s title '%s'" % par] + else: + par = gr + plot += ["'%s' using %s:%s title '%s' with %s" % par] if plot: g('plot ' + ', '.join(plot)) if format != 'show' and fname: diff --git a/plot_pm.py b/plot_pm.py index c2b501c..2975b45 100755 --- a/plot_pm.py +++ b/plot_pm.py @@ -9,11 +9,8 @@ from gnuplot import gnuplot, FORMATS options = [ o(None, '--shared-l3', action='store_true', dest='sharedL3'), - o(None, '--all', action='store_true', dest='alloh', help='Print a single \ -plot for all overheads (assume the file list contains all different \ -overheads to plot)'), o(None, '--name', action='store', dest='name', help='where to store the \ -output WHEN using --all'), +output'), o(None, '--type', action='store', dest='type', type='choice', choices=['hard','soft'], help='type of plot'), o('-f', '--format', action='store', dest='format', type='choice', @@ -24,11 +21,11 @@ output WHEN using --all'), defaults = { 'sharedL3' : False, - 'alloh' : False, + 'name' : 'test', 'type' : 'hard', 'format' : 'show', 'xrange' : (74.5, 250.5), - 'yrange' : (0, 5000), + 'yrange' : (100, 1700), 'xticks' : (0, 25), 'yticks' : (0, 250), 'title' : None, @@ -37,7 +34,17 @@ defaults = { 'paper' : False, 'split' : False, 'wide' : False, - } +} + +JOB_TYPE = { + 'NP' : 'Non Preemptive jobs', + 'P' : 'Preemptive jobs' +} + +BWORK = { + 'bg' : 'with background work', + 'idle' : 'without background work' +} def overhead_heading(conf, sharedL3=False): ovd_type = 'unknowkn overhead' @@ -52,107 +59,76 @@ def overhead_heading(conf, sharedL3=False): elif conf['ovd'] == 'l2cache': ovd_type = 'Shared L2' elif conf['ovd'] == 'offchip': - ovd_type = 'Off Chip' + ovd_type = 'Diff. Socket' return ovd_type class PmPlotter(defapp.App): def __init__(self): defapp.App.__init__(self, options, defaults, no_std_opts=True) - # "private" values needed when --all options is given self.graphs_list = [] self.title = '' + self.fname = {'ovd':set([]), 'wss':set([])} self.tmpfile_list = [] self.conf = [] + def compose_name(self, conf): + name = 'pm_' + name += ('avg' if 'soft' in conf else 'wc') + name += '_wss=' + wsses = [] + for i in self.fname['wss']: + wsses.append(i) + for i in sorted(wsses, key=int): + name += str(i) + ',' + name = name[0:-1] + name += '_ovd=' + for i in self.fname['ovd']: + name += str(i) + ',' + name = name[0:-1] + return name + def plot(self, graphs, title, name, conf, **xtra): + name = self.compose_name(conf) + print name gnuplot(graphs, title=title, xlabel=self.options.xlabel, ylabel=self.options.ylabel + (' [avg]' if 'soft' in conf else ' [max]'), - xrange=self.options.xrange, - yrange=self.options.yrange, - xticks=self.options.xticks, - yticks=self.options.yticks, + #xrange=self.options.xrange, + #yrange=self.options.yrange, + #xticks=self.options.xticks, + #yticks=self.options.yticks, format=self.options.format, + style=('yerrorlines' if 'soft' in conf else 'linespoints'), fname=name, **xtra) - def plot_wide(self, graphs, title, name, conf, **xtra): - tops = 'rounded size 16cm,6.5cm' - gnuplot(graphs, title=title, - xlabel=self.options.xlabel, - ylabel=self.options.ylabel + - (' [avg]' if 'soft' in conf else ' [max]'), - xrange=self.options.xrange, - yrange=self.options.yrange, - xticks=self.options.xticks, - yticks=self.options.yticks, - format=self.options.format, - fname=name, - term_opts=tops, - **xtra) - - def plot_paper(self, graphs, title, name, conf, **xtra): - tops = 'color solid font "Helvetica,10" linewidth 1.0 rounded size 16cm,8.5cm' - gnuplot(graphs, title=title, - xlabel=self.options.xlabel, - ylabel=self.options.ylabel + - (' [avg]' if 'soft' in conf else ' [max]'), - xrange=self.options.xrange, - yrange=self.options.yrange, - xticks=self.options.xticks, - yticks=self.options.yticks, - format=self.options.format, - fname=name, - key='off', - style='lines lw 7', - term_opts=tops) - - def plot_pm(self, tmpfile, name, conf): - title = overhead_heading(conf, sharedL3=self.options.sharedL3) - title += ' ; ' + scenario_heading(conf, want_period=True) - plugin = conf['plugin'] - if 'soft' in conf: - name = 'soft_' + name - else: - name = 'hard_' + name - wsslist = conf['wss'].split(',') - graphs = [] - wsspos = 2 - if 'soft' in conf: - wsspos += 1 - for i in wsslist: - label = plugin + ' WSS=' + i - graphs.append((tmpfile, 1, wsspos, label)) - wsspos += 2 - - if self.options.paper and self.options.format == 'pdf': - self.plot_paper(graphs, title, name, conf) - elif self.options.wide and self.options.format == 'pdf': - self.plot_wide(graphs, title, name, conf) - else: - self.plot(graphs, title, name, conf) + def compose_title(self, conf): + if self.title == '': + if 'soft' in conf: + self.title = 'measured average overhead to 2nd hot access' + else: + self.title = 'measured maximum overhead to 2nd hot access' def add_to_graph_list(self, tmpfile, name, conf): - #self.title += overhead_heading(conf, sharedL3=self.options.sharedL3) - #self.title += ' ; ' + self.compose_title(conf) wsslist = conf['wss'].split(',') + self.fname['ovd'].add(conf['ovd']) wsspos = 2 if 'soft' in conf: wsspos += 1 for i in wsslist: - label = conf['plugin'] + ' ' + conf['ovd'] + ' WSS=' + i - self.graphs_list.append((tmpfile, 1, wsspos, label)) - wsspos += 2 - - def plot_graph_list(self, type, name='blob'): - self.title = self.title[0:-3] - if self.options.paper and self.options.format == 'pdf': - self.plot_paper(self.graphs_list, self.title, name, type) - elif self.options.wide and self.options.format == 'pdf': - self.plot_wide(self.graphs_list, self.title, name, type) - else: - self.plot(self.graphs_list, self.title, name, type) + self.fname['wss'].add(i) + label = conf['ovd'] + ' WSS=' + i + if 'soft' in conf: + self.graphs_list.append((tmpfile, 1, wsspos, wsspos+1, \ + wsspos+2, label)) + else: + self.graphs_list.append((tmpfile, 1, wsspos, label)) + wsspos += 4 + + def plot_graph_list(self, type, name): + self.plot(self.graphs_list, self.title, name, type) # delete temporary data files for tmp in self.tmpfile_list: @@ -170,20 +146,12 @@ class PmPlotter(defapp.App): if tmpfile: if 'pm' in conf: conf[self.options.type] = None - if self.options.alloh: - self.add_to_graph_list(tmpfile.name, name, conf) - else: - self.plot_pm(tmpfile.name, name, conf) + self.add_to_graph_list(tmpfile.name, name, conf) else: self.err("Skipped '%s'; unknown experiment type." % bname) - - if self.options.alloh: - # keep a list of temporary data files - self.tmpfile_list.append(tmpfile) - - else: - del tmpfile # removes temp file + # keep a list of temporary data files + self.tmpfile_list.append(tmpfile) else: self.err("Skipped '%s'; it dosn't appear to contain data." % bname) @@ -192,9 +160,8 @@ class PmPlotter(defapp.App): for datafile in self.args: self.plot_file(datafile) - if self.options.alloh: - # also clean up tmp data files - self.plot_graph_list(self.options.type, self.options.name) + # also clean up tmp data files + self.plot_graph_list(self.options.type, self.options.name) if __name__ == "__main__": PmPlotter().launch() -- cgit v1.2.2