baseline. The baseline is the first function, which typically is the builtin
function.
"""
+import math
import matplotlib as mpl
mpl.use('Agg')
pylab.savefig('%s-%s.png' % (f, v), bbox_inches='tight')
-def process_results(results, attrs, funcs, base_func, graph, no_diff, no_header):
+def process_results(results, attrs, funcs, base_func, graph, no_diff,
+ no_header, gmean):
""" Process results and print them
Args:
print("%36s%s" % (' ', '\t'.join(ifuncs)))
print("=" * 120)
+ mean_row = [0 for i in range(len(ifuncs))]
+ total=0
graph_res = {}
for res in results['functions'][f]['results']:
try:
key = ', '.join(attr_list)
sys.stdout.write('%36s: ' % key)
graph_res[key] = res['timings']
+
for t in res['timings']:
if selected[i]:
+ if gmean:
+ mean_row[i] = mean_row[i]+math.log(t)
sys.stdout.write ('%12.2f' % t)
if not no_diff:
if i != base_index:
if graph:
draw_graph(f, v, results['functions'][f]['ifuncs'], graph_res)
+ if gmean:
+ print("=" * 120)
+ total = len(results['functions'][f]['results'])
+ sys.stdout.write ('Geo-mean (for %s inputs)'%total)
+ for m in mean_row:
+ sys.stdout.write ('%12.2f' % (math.exp(m/total)))
def main(args):
"""Program Entry Point
funcs = None
results = parse_file(args.input, args.schema)
- process_results(results, attrs, funcs, base_func, args.graph, args.no_diff, args.no_header)
+ process_results(results, attrs, funcs, base_func, args.graph, args.no_diff,
+ args.no_header, args.gmean)
return os.EX_OK
help='Do not print the difference from baseline.')
parser.add_argument('--no-header', action='store_true',
help='Do not print the header.')
+ parser.add_argument('--gmean', action='store_true',
+ help='Print the geometric mean at the end of the output.')
args = parser.parse_args()
sys.exit(main(args))