29,31c29,33
< class StatOutput(object):
< def __init__(self, name, jobfile, info, stat=None, binstats=None):
< self.name = name
---
> from chart import ChartOptions
>
> class StatOutput(ChartOptions):
> def __init__(self, jobfile, info, stat=None, binstats=None):
> super(StatOutput, self).__init__()
35d36
< self.label = self.name
39c40
< def printdata(self, bin = None, printmode = 'G'):
---
> def printdata(self, name, bin = None, printmode = 'G'):
43c44
< print '%s %s stats' % (self.name, bin)
---
> print '%s %s stats' % (name, bin)
72c73
< def display(self, binned = False, printmode = 'G'):
---
> def display(self, name, binned = False, printmode = 'G'):
74,77c75,78
< self.printdata('kernel', printmode)
< self.printdata('idle', printmode)
< self.printdata('user', printmode)
< self.printdata('interrupt', printmode)
---
> self.printdata(name, 'kernel', printmode)
> self.printdata(name, 'idle', printmode)
> self.printdata(name, 'user', printmode)
> self.printdata(name, 'interrupt', printmode)
79,80c80,81
< print '%s total stats' % self.name
< self.printdata(printmode=printmode)
---
> print '%s total stats' % name
> self.printdata(name, printmode=printmode)
82c83
< def graph(self, graphdir):
---
> def graph(self, name, graphdir, proxy=None):
86c87,88
< import os, re
---
> import os, re, urllib
> from jobfile import crossproduct
91,92c93,94
< groupopts = None
< baropts = None
---
> groupopts = []
> baropts = []
96,99c98
< if groupopts is not None:
< raise AttributeError, \
< 'Two groups selected for graph group'
< groupopts = group.subopts()
---
> groupopts.append(group.subopts())
102,105c101
< if baropts is not None:
< raise AttributeError, \
< 'Two groups selected for graph bars'
< baropts = group.subopts()
---
> baropts.append(group.subopts())
110c106
< if groupopts is None:
---
> if not groupopts:
113c109
< if baropts is None:
---
> if not baropts:
115a112,114
> groupopts = [ group for group in crossproduct(groupopts) ]
> baropts = [ bar for bar in crossproduct(baropts) ]
>
119c118
< html = file(joinpath(directory, '%s.html' % self.name), 'w')
---
> html = file(joinpath(directory, '%s.html' % name), 'w')
121c120
< print >>html, '<title>Graphs for %s</title>' % self.name
---
> print >>html, '<title>Graphs for %s</title>' % name
122a122
> html.flush()
124a125,126
> chart = BarChart(self)
>
131c133
< job = self.jobfile.job(options + [ gopt, bopt ])
---
> job = self.jobfile.job(options + gopt + bopt)
134a137,139
> if proxy:
> import db
> proxy.dict['system'] = self.info[job.system]
135a141,144
> if val is None:
> print 'stat "%s" for job "%s" not found' % \
> (self.stat, job)
>
154c163
< data[i][j] = [] * stacked
---
> data[i][j] = [ 0.0 ] * stacked
162,170c171,177
< bar_descs = [ opt.desc for opt in baropts ]
< group_descs = [ opt.desc for opt in groupopts ]
< if stacked:
< try:
< legend = self.info.rcategories
< except:
< legend = [ str(i) for i in xrange(stacked) ]
< else:
< legend = bar_descs
---
> x = data.shape[0]
> y = data.shape[1]
> xkeep = [ i for i in xrange(x) if data[i].sum() != 0 ]
> ykeep = [ i for i in xrange(y) if data[:,i].sum() != 0 ]
> data = data.take(xkeep, axis=0)
> data = data.take(ykeep, axis=1)
> chart.data = data
172,173c179,195
< chart = BarChart(data=data, xlabel='Benchmark', ylabel=self.label,
< legend=legend, xticks=group_descs)
---
> gopts = [ groupopts[i] for i in xkeep ]
> bopts = [ baropts[i] for i in ykeep ]
>
> bdescs = [ ' '.join([o.desc for o in opt]) for opt in bopts]
> gdescs = [ ' '.join([o.desc for o in opt]) for opt in gopts]
>
> if chart.legend is None:
> if stacked:
> try:
> chart.legend = self.info.rcategories
> except:
> chart.legend = [ str(i) for i in xrange(stacked) ]
> else:
> chart.legend = bdescs
>
> if chart.xticks is None:
> chart.xticks = gdescs
179c201,205
< filename = '%s-%s.png' % (self.name, ':'.join(names))
---
> if names[0] == 'run':
> names = names[1:]
> descs = descs[1:]
>
> basename = '%s-%s' % (name, ':'.join(names))
181,184d206
< filepath = joinpath(directory, filename)
< chart.savefig(filepath)
< filename = re.sub(':', '%3A', filename)
< print >>html, '''%s<br><img src="%s"><br>''' % (desc, filename)
185a208,217
> pngname = '%s.png' % basename
> psname = '%s.eps' % re.sub(':', '-', basename)
> epsname = '%s.ps' % re.sub(':', '-', basename)
> chart.savefig(joinpath(directory, pngname))
> chart.savefig(joinpath(directory, epsname))
> chart.savefig(joinpath(directory, psname))
> html_name = urllib.quote(pngname)
> print >>html, '''%s<br><img src="%s"><br>''' % (desc, html_name)
> html.flush()
>