From edde9793da12398d11909a1be2041db93080d22a Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Sun, 20 Feb 2011 12:05:00 -0500 Subject: add support for plotting trendlines --- oplot.py | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 87 insertions(+), 8 deletions(-) (limited to 'oplot.py') diff --git a/oplot.py b/oplot.py index 89e0ef0..86d292c 100755 --- a/oplot.py +++ b/oplot.py @@ -75,6 +75,10 @@ TXT = { } +HOST_CPUS = { + 'ludwig' : 24, +} + def get_stats_label(samples): avg = numpy.mean(samples) med = numpy.median(samples) @@ -172,25 +176,34 @@ class OverheadPlotter(defapp.App): p = self.make_plot(name) + samples_label = "samples: total=%d filtered=%d (%.2f%%)" % \ + (len(data), len(data) - len(samples), discarded) - iqr_label = "\\n".join(["samples: total=%d filtered=%d (%.2f%%)", - "IQR: extent=%d threshold=%.2fus", - ]) % \ - (len(data), len(data) - len(samples), discarded, - self.options.extent, iqr_max) + if self.options.extent: + iqr_label = "IQR: extent=%d threshold=%.2fus" % \ + (self.options.extent, iqr_max) + elif discarded > 0: + iqr_label = "manual threshold=1000us [IQR not applied]" + else: + iqr_label = "[IQR filter not applied]" + samples_label = "samples: total=%d" % len(data) + + data_label = "%s\\n%s" % (samples_label, iqr_label) p.labels = [label(0.5, 0.9, get_stats_label(samples), coord=['graph', 'screen'], align='center'), - label(0.98, 0.95, iqr_label, + label(0.98, 0.95, data_label, coord=['graph', 'graph'], align='right')] (hist, fname, edges) = self.write_histogram(samples, name) p.setup_histogram(gap=1, boxwidth=1.0) - p.title = "%s: measured %s for %s tasks per processor (host=%s)" \ - % (conf['scheduler'], TXT[conf['overhead']], conf['n'], conf['host']) + p.title = "%s: measured %s for %s task%s per processor (host=%s)" \ + % (conf['scheduler'], TXT[conf['overhead']], + conf['n'], 's' if conf['n'] != '1' else '', + conf['host']) if self.options.normalize: p.ylabel = "fraction of samples" @@ -220,6 +233,71 @@ class OverheadPlotter(defapp.App): self.render(p) + def prepare_trends(self, datafile, name, conf): + data = load_csv_file(datafile) + if 'host' in conf and conf['host'] in HOST_CPUS: + cpus = HOST_CPUS[conf['host']] + if conf['scheduler'].endswith('-RM'): + cpus -= 1 + else: + cpus = 1 + # format + n_idx = 2 + wc_idx = 5 + avg_idx = 6 + std_idx = 9 + + rows = [ [r[n_idx] * cpus, + r[wc_idx], + r[avg_idx], + r[std_idx]] + for r in data] + + max_y = numpy.amax(data[:,wc_idx]) + + return (self.write(rows, name), cpus, max_y) + + def plot_trends(self, datafile, name, conf): + fname, cpus, max_y = self.prepare_trends(datafile, name, conf) + + p = self.make_plot(name) + + p.title = "measured %s under %s scheduling" \ + % (TXT[conf['overhead']], conf['scheduler']) + + p.ylabel = "overhead in microseconds" + p.xlabel = "number of tasks" + + if self.options.xmax: + p.xrange = (0, self.options.xmax) + else: + p.xrange = (0, ceil(cpus * 20 / 100.0) * 100) + + if self.options.ymax: + p.yrange = (0, self.options.ymax) + else: + p.yrange = (0, (ceil(max_y / 50.0)) * 50) + + p.xticks = (0, max(cpus, 10)) + p.curves = [curve(fname, xcol=1, ycol=2, title="maximum"), + curve(fname, xcol=1, ycol=3, style="lines", title='average'), + curve(fname, xcol=1, ycol=3, error=4, title="std. deviation")] + + #### Styling. + + if not self.setup_png(p): + p.rounded_caps = True + p.font = 'Helvetica' + + p.font_size = '10' + p.size = ('20cm', '10cm') + p.monochrome = False + p.dashed_lines = False + p.key = 'left top' + p.default_style = 'linespoints lw 1' + + self.render(p) + def plot_file(self, datafile): bname = basename(datafile) @@ -227,6 +305,7 @@ class OverheadPlotter(defapp.App): conf = decode(name) plotters = { 'taskset' : self.plot_samples, + 'otrend' : self.plot_trends, } for plot_type in plotters: -- cgit v1.2.2