Alien-SVN
view release on metacpan or search on metacpan
src/subversion/tools/dev/benchmarks/suite1/benchmark.py view on Meta::CPAN
print '\n'.join(s)
def cmdline_compare(db, options, *args):
run_kinds = parse_timings_selections(db, *args)
if len(run_kinds) < 2:
bail("Need at least two sets of timings to compare.")
left_kind = run_kinds[0]
leftq = TimingQuery(db, left_kind)
left = leftq.get_timings()
if not left:
bail("No timings for %s" % left_kind.label())
for run_kind_idx in range(1, len(run_kinds)):
right_kind = run_kinds[run_kind_idx]
rightq = TimingQuery(db, right_kind)
right = rightq.get_timings()
if not right:
print "No timings for %s" % right_kind.label()
continue
label = 'Compare %s to %s' % (right_kind.label(), left_kind.label())
s = [label]
verbose = options.verbose
if not verbose:
s.append(' N avg operation')
else:
s.append(' N min max avg operation')
command_names = [name for name in leftq.get_sorted_command_names()
if name in right]
if options.command_names:
command_names = [name for name in command_names
if name in options.command_names]
for command_name in command_names:
left_N, left_min, left_max, left_avg = left[command_name]
right_N, right_min, right_max, right_avg = right[command_name]
N_str = '%s/%s' % (n_label(left_N), n_label(right_N))
avg_str = '%7.2f|%+7.3f' % (do_div(left_avg, right_avg),
do_diff(left_avg, right_avg))
if not verbose:
s.append('%9s %-16s %s' % (N_str, avg_str, command_name))
else:
min_str = '%7.2f|%+7.3f' % (do_div(left_min, right_min),
do_diff(left_min, right_min))
max_str = '%7.2f|%+7.3f' % (do_div(left_max, right_max),
do_diff(left_max, right_max))
s.append('%9s %-16s %-16s %-16s %s' % (N_str, min_str, max_str, avg_str,
command_name))
s.extend([
'(legend: "1.23|+0.45" means: slower by factor 1.23 and by 0.45 seconds;',
' factor < 1 and seconds < 0 means \'%s\' is faster.'
% right_kind.label(),
' "2/3" means: \'%s\' has 2 timings on record, the other has 3.)'
% left_kind.label()
])
print '\n'.join(s)
# ------------------------------------------------------- charts
def cmdline_chart_compare(db, options, *args):
import matplotlib
matplotlib.use('Agg')
import numpy as np
import matplotlib.pylab as plt
labels = []
timing_sets = []
command_names = None
run_kinds = parse_timings_selections(db, *args)
# iterate the timings selections and accumulate data
for run_kind in run_kinds:
query = TimingQuery(db, run_kind)
timings = query.get_timings()
if not timings:
print "No timings for %s" % run_kind.label()
continue
labels.append(run_kind.label())
timing_sets.append(timings)
# it only makes sense to compare those commands that have timings
# in the first selection, because that is the one everything else
# is compared to. Remember the first selection's command names.
if not command_names:
command_names = query.get_sorted_command_names()
if len(timing_sets) < 2:
bail("Not enough timings")
if options.command_names:
command_names = [name for name in command_names
if name in options.command_names]
chart_path = options.chart_path
if not chart_path:
chart_path = 'compare_' + '_'.join(
[ filesystem_safe_string(l) for l in labels ]
) + '.svg'
N = len(command_names)
M = len(timing_sets) - 1
if M < 2:
M = 2
group_positions = np.arange(N) # the y locations for the groups
( run in 0.353 second using v1.01-cache-2.11-cpan-ceb78f64989 )