From b45afe309c61d9590ba523a5f0c37469fcdc4553 Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Wed, 13 May 2009 23:54:09 -0400 Subject: working plot ohead with paper mode --- plot_ohead.py | 144 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 116 insertions(+), 28 deletions(-) (limited to 'plot_ohead.py') diff --git a/plot_ohead.py b/plot_ohead.py index 974832b..430707e 100755 --- a/plot_ohead.py +++ b/plot_ohead.py @@ -1,38 +1,126 @@ #!/usr/bin/env python + +import defapp +from os.path import splitext, basename +from optparse import make_option as o + from gnuplot import gnuplot, FORMATS -plugins = ['GSN-EDF', 'G-EDF', 'GQ-EDF', 'GHQ-EDF'] -master = ['NO_CPU', '3'] -events = ['SCHED', 'SCHED2', 'TICK', 'CXS', 'RELEASE', 'SEND_RESCHED'] +PLUGINS = ['GSN-EDF', 'G-EDF', 'GQ-EDF', 'GHQ-EDF'] +MASTER = ['NO_CPU', '3'] +EVENTS = ['SCHED', 'SCHED2', 'TICK', 'CXS', 'RELEASE', 'SEND_RESCHED'] + +DATA = ['avg', 'wc'] + +options = [ + o('-f', '--format', action='store', dest='format', type='choice', + choices=FORMATS, help='output format'), + o(None, '--paper', action='store_true', dest='paper'), + o('-e', '--events', action='append', dest='events', type='choice', + choices=EVENTS), + o('-m', '--master', action='append', dest='master', type='choice', + choices=MASTER), + o('-p', '--plugins', action='append', dest='plugins', type='choice', + choices=PLUGINS), + o('-d', '--data', action='append', dest='data', type='choice', + choices=DATA), + ] + +defaults = { + 'format' : 'show', + 'xrange' : (45, 455), + 'yrange' : (0, 400), + 'xticks' : (50, 50), + 'yticks' : (0, 10), + 'title' : None, + 'xlabel' : 'number of tasks', + 'ylabel' : 'overhead (us)', + 'paper' : False, + 'events' : [], + 'plugins' : [], + 'master' : [], + 'data' : [], + } + + +ev_name = { + 'RELEASE' : 'release overhead', + 'TICK' : 'tick overhead', + 'SCHED' : 'scheduling overhead', + 'SCHED2' : 'timer re-arming overhead', + 'SEND_RESCHED' : 'IPI latency', + 'CXS' : 'context-switching overhead', +} def graph(plugin, master, event, wc): return ['%s.R-%s.%s.csv' % (plugin, master, event), 1, 3 if wc else 2, '%s %s %s %s' % (plugin, event, 'RM' if master != 'NO_CPU' else '', 'WC' if wc else 'AVG')] -def by_event(wc): - for e in events: - gs = [] - for p in plugins: - for m in master: - if (p != 'GHQ-EDF' or m == 'NO_CPU') and \ - (p != 'GQ-EDF' or e != 'SEND_RESCHED'): - gs += [graph(p, m, e, wc)] - gnuplot(gs, title='%s %s' % (e, 'WC' if wc else 'AVG')) - -def by_plugin(wc): - for p in plugins: - gs = [] - for e in events: - for m in master: - if (p != 'GHQ-EDF' or m == 'NO_CPU') and \ - (p != 'GQ-EDF' or e != 'SEND_RESCHED'): - gs += [graph(p, m, e, wc)] - gnuplot(gs, title='%s %s' % (p, 'WC' if wc else 'AVG')) - -#by_event(True) -#by_event(False) - -by_plugin(True) -by_plugin(False) +class OheadPlotter(defapp.App): + def __init__(self): + defapp.App.__init__(self, options, defaults, no_std_opts=True) + if not self.options.events: + self.options.events = EVENTS + if not self.options.plugins: + self.options.plugins = PLUGINS + if not self.options.master: + self.options.master = MASTER + if not self.options.data: + self.options.data = DATA + + def plot(self, graphs, title, name, **xtra): + if self.options.paper: + 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, + 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) + else: + gnuplot(graphs, title=title, + xlabel=self.options.xlabel, + ylabel=self.options.ylabel, +# xrange=self.options.xrange, +# yrange=self.options.yrange, + xticks=self.options.xticks, +# yticks=self.options.yticks, + format=self.options.format, + fname=name, **xtra) + + def do_by_event(self, _): + for d in self.options.data: + wc = d == 'wc' + for e in self.options.events: + gs = [] + for p in self.options.plugins: + for m in self.options.master: + if (p != 'GHQ-EDF' or m == 'NO_CPU') and \ + (p != 'GQ-EDF' or e != 'SEND_RESCHED'): + gs += [graph(p, m, e, wc)] + fname = '%s.%s' % (e, d) + title = '%s %s' % ('worst-case' if wc else 'average-case' , ev_name[e]) + self.plot(gs, title=title, name=fname) + + def do_by_plugin(self, _): + for p in self.options.plugins: + gs = [] + for d in self.options.data: + wc = d == 'wc' + for e in self.options.events: + for m in self.options.master: + if (p != 'GHQ-EDF' or m == 'NO_CPU') and \ + (p != 'GQ-EDF' or e != 'SEND_RESCHED'): + gs += [graph(p, m, e, wc)] + self.plot(gs, title='%s %s' % (p, 'WC' if wc else 'AVG'), name='') + +if __name__ == "__main__": + OheadPlotter().launch() -- cgit v1.2.2