Alien-SVN
view release on metacpan or search on metacpan
src/subversion/tools/dev/benchmarks/suite1/benchmark.py view on Meta::CPAN
(div_avg, ),
barheight,
color=col, edgecolor='white')
plot1.text(0., y + height/2.,
'%s %+5.1f%%' % (label, div_avg),
ha='right', va='center', size='small',
rotation=0, family='monospace')
plot2.barh((y, ),
(diff_val, ),
barheight,
color=col, edgecolor='white')
plot2.text(0., y + height/2.,
'%s %+6.2fs' % (label, diff_val),
ha='right', va='center', size='small',
rotation=0, family='monospace')
for p in (plot1, plot2):
xlim = list(p.get_xlim())
if xlim[1] < 10.:
xlim[1] = 10.
# make sure the zero line is far enough right so that the annotations
# fit inside the chart. About half the width should suffice.
if xlim[0] > -xlim[1]:
xlim[0] = -xlim[1]
p.set_xlim(*xlim)
p.set_xticks((0,))
p.set_yticks(group_positions + (height / 2.))
p.set_yticklabels(())
p.set_ylim((len(command_names), 0))
p.grid()
plot1.set_xticklabels(('+-0%',), rotation=0)
plot1.set_title('Average runtime change from %s in %%' % labels[0],
size='medium')
plot2.set_xticklabels(('+-0s',), rotation=0)
plot2.set_title('Average runtime change from %s in seconds' % labels[0],
size='medium')
margin = 1./(2 + N*M)
titlemargin = 0
if options.title:
titlemargin = margin * 1.5
fig.subplots_adjust(left=0.005, right=0.995, wspace=0.3, bottom=margin,
top=1.0-margin-titlemargin)
ystep = (1.0 - 2.*margin - titlemargin) / len(command_names)
for idx,command_name in enumerate(command_names):
ylabel = '%s\nvs. %.1fs' % (
command_name,
left[command_name][3])
ypos=1.0 - margin - titlemargin - ystep/M - ystep * idx
plt.figtext(0.5, ypos,
command_name,
ha='center', va='top',
size='medium', weight='bold')
plt.figtext(0.5, ypos - ystep/(M+1),
'%s\n= %.2fs' % (
labels[0], left[command_name][3]),
ha='center', va='top',
size='small')
if options.title:
plt.figtext(0.5, 1. - titlemargin/2, options.title, ha='center',
va='center', weight='bold')
plt.savefig(chart_path)
print 'wrote chart file:', chart_path
# ------------------------------------------------------------ main
# Custom option formatter, keeping newlines in the description.
# adapted from:
# http://groups.google.com/group/comp.lang.python/msg/09f28e26af0699b1
import textwrap
class IndentedHelpFormatterWithNL(optparse.IndentedHelpFormatter):
def format_description(self, description):
if not description: return ""
desc_width = self.width - self.current_indent
indent = " "*self.current_indent
bits = description.split('\n')
formatted_bits = [
textwrap.fill(bit,
desc_width,
initial_indent=indent,
subsequent_indent=indent)
for bit in bits]
result = "\n".join(formatted_bits) + "\n"
return result
if __name__ == '__main__':
parser = optparse.OptionParser(formatter=IndentedHelpFormatterWithNL())
# -h is automatically added.
### should probably expand the help for that. and see about -?
parser.add_option('-v', '--verbose', action='store_true', dest='verbose',
help='Verbose operation')
parser.add_option('-b', '--svn-bin-dir', action='store', dest='svn_bin_dir',
default='',
help='Specify directory to find Subversion binaries in')
parser.add_option('-f', '--db-path', action='store', dest='db_path',
default='benchmark.db',
help='Specify path to SQLite database file')
parser.add_option('-o', '--chart-path', action='store', dest='chart_path',
help='Supply a path for chart output.')
parser.add_option('-c', '--command-names', action='store',
dest='command_names',
help='Comma separated list of command names to limit to.')
parser.add_option('-t', '--title', action='store',
dest='title',
help='For charts, a title to print in the chart graphics.')
parser.set_description(__doc__)
parser.set_usage('')
options, args = parser.parse_args()
def usage(msg=None):
parser.print_help()
if msg:
print
print msg
bail()
( run in 1.678 second using v1.01-cache-2.11-cpan-97f6503c9c8 )