def plot(records, bytes, function): records = [ x for x in records if x.bytes == bytes and x.function == function ] variants = libplot.unique(records, 'variant', prefer='this') alignments = libplot.unique(records, ('src_alignment', 'dst_alignment')) X = pylab.arange(len(alignments)) width = 1.0 / (len(variants) + 1) colours = libplot.make_colours() pylab.figure(1).set_size_inches((16, 12)) pylab.clf() for i, variant in enumerate(variants): heights = [] for alignment in alignments: matches = [ x for x in records if x.variant == variant and x.src_alignment == alignment[0] and x.dst_alignment == alignment[1] ] if matches: vals = [ match.bytes * match.loops / match.elapsed / (1024 * 1024) for match in matches ] mean = sum(vals) / len(vals) heights.append(mean) else: heights.append(0) pylab.bar(X + i * width, heights, width, color=colours.next(), label=variant) axes = pylab.axes() if libplot.alignments_equal(alignments): alignment_labels = ["%s" % x[0] for x in alignments] else: alignment_labels = ["%s:%s" % (x[0], x[1]) for x in alignments] axes.set_xticklabels(alignment_labels) axes.set_xticks(X + 0.5) pylab.title( 'Performance of different variants of %(function)s for %(bytes)d byte blocks' % locals()) pylab.xlabel('Alignment') pylab.ylabel('Rate (MB/s)') pylab.legend(loc='lower right', ncol=3) pylab.grid() pylab.savefig('alignment-%(function)s-%(bytes)d.png' % locals(), dpi=72)
def plot(records, field, scale, ylabel): variants = unique(records, 'variant') tests = unique(records, 'test') colours = libplot.make_colours() # A little hack. We want the 'all' record to be drawn last so # that it's obvious on the graph. Assume that no tests come # before it alphabetically variants.reverse() for test in tests: for variant in variants: v = [x for x in records if x.test == test and x.variant == variant] v.sort(key=lambda x: x.size) V = pylab.array([(x.size, getattr(x, field)) for x in v]) # Ensure our results appear order = 1 if variant == 'this' else 0 try: # A little hack. We want the 'all' to be obvious on # the graph if variant == 'all': pylab.scatter(V[:, 0], V[:, 1] / scale, label=variant) pylab.plot(V[:, 0], V[:, 1] / scale) else: pylab.plot(V[:, 0], V[:, 1] / scale, label=variant, zorder=order, c=colours.next()) except Exception, ex: # michaelh1 likes to run this script while the test is # still running which can lead to bad data print ex, 'on %s of %s' % (variant, test) pylab.legend(loc='lower right', ncol=2, prop={'size': 'small'}) pylab.xlabel('Block size (B)') pylab.ylabel(ylabel) pylab.title('%s %s' % (test, field)) pylab.grid() pylab.savefig('%s-%s.png' % (test, field), dpi=100) pylab.semilogx(basex=2) pylab.savefig('%s-%s-semilog.png' % (test, field), dpi=100) pylab.clf()
def plot(records, field, scale, ylabel): variants = unique(records, 'variant') tests = unique(records, 'test') colours = libplot.make_colours() # A little hack. We want the 'all' record to be drawn last so # that it's obvious on the graph. Assume that no tests come # before it alphabetically variants.reverse() for test in tests: for variant in variants: v = [x for x in records if x.test==test and x.variant==variant] v.sort(key=lambda x: x.size) V = pylab.array([(x.size, getattr(x, field)) for x in v]) # Ensure our results appear order = 1 if variant == 'this' else 0 try: # A little hack. We want the 'all' to be obvious on # the graph if variant == 'all': pylab.scatter(V[:,0], V[:,1]/scale, label=variant) pylab.plot(V[:,0], V[:,1]/scale) else: pylab.plot(V[:,0], V[:,1]/scale, label=variant, zorder=order, c = colours.next()) except Exception, ex: # michaelh1 likes to run this script while the test is # still running which can lead to bad data print ex, 'on %s of %s' % (variant, test) pylab.legend(loc='lower right', ncol=2, prop={'size': 'small'}) pylab.xlabel('Block size (B)') pylab.ylabel(ylabel) pylab.title('%s %s' % (test, field)) pylab.grid() pylab.savefig('%s-%s.png' % (test, field), dpi=100) pylab.semilogx(basex=2) pylab.savefig('%s-%s-semilog.png' % (test, field), dpi=100) pylab.clf()
def plot(records, bytes, function): records = [x for x in records if x.bytes==bytes and x.function==function] variants = libplot.unique(records, 'variant', prefer='this') alignments = libplot.unique(records, ('src_alignment', 'dst_alignment')) X = pylab.arange(len(alignments)) width = 1.0/(len(variants)+1) colours = libplot.make_colours() pylab.figure(1).set_size_inches((16, 12)) pylab.clf() for i, variant in enumerate(variants): heights = [] for alignment in alignments: matches = [x for x in records if x.variant==variant and x.src_alignment==alignment[0] and x.dst_alignment==alignment[1]] if matches: vals = [match.bytes*match.loops/match.elapsed/(1024*1024) for match in matches] mean = sum(vals)/len(vals) heights.append(mean) else: heights.append(0) pylab.bar(X+i*width, heights, width, color=colours.next(), label=variant) axes = pylab.axes() if libplot.alignments_equal(alignments): alignment_labels = ["%s" % x[0] for x in alignments] else: alignment_labels = ["%s:%s" % (x[0], x[1]) for x in alignments] axes.set_xticklabels(alignment_labels) axes.set_xticks(X + 0.5) pylab.title('Performance of different variants of %(function)s for %(bytes)d byte blocks' % locals()) pylab.xlabel('Alignment') pylab.ylabel('Rate (MB/s)') pylab.legend(loc='lower right', ncol=3) pylab.grid() pylab.savefig('alignment-%(function)s-%(bytes)d.png' % locals(), dpi=72)
def plot(records, bytes): records = [x for x in records if x.bytes==bytes] variants = libplot.unique(records, 'variant', prefer='this') functions = libplot.unique(records, 'function') X = pylab.arange(len(functions)) width = 1.0/(len(variants)+1) colours = libplot.make_colours() pylab.figure(1).set_size_inches((16, 12)) pylab.clf() for i, variant in enumerate(variants): heights = [] for function in functions: matches = [x for x in records if x.variant==variant and x.function==function and x.src_alignment==8] if matches: vals = [match.bytes*match.loops/match.elapsed/(1024*1024) for match in matches] mean = sum(vals)/len(vals) heights.append(mean) else: heights.append(0) pylab.bar(X+i*width, heights, width, color=colours.next(), label=variant) axes = pylab.axes() axes.set_xticklabels(functions) axes.set_xticks(X + 0.5) pylab.title('Performance of different variants for %d byte blocks' % bytes) pylab.ylabel('Rate (MB/s)') pylab.legend(loc='upper left', ncol=3) pylab.grid() pylab.savefig('top-%06d.png' % bytes, dpi=72)
def plot(records, function, alignment=None, scale=1): variants = libplot.unique(records, 'variant', prefer='this') records = [x for x in records if x.function==function] if alignment != None: records = [x for x in records if x.src_alignment==alignment[0] and x.dst_alignment==alignment[1]] alignments = libplot.unique(records, ('src_alignment', 'dst_alignment')) if len(alignments) != 1: return False if libplot.alignments_equal(alignments): aalignment = alignments[0][0] else: aalignment = "%s:%s" % (alignments[0][0], alignments[0][1]) bytes = libplot.unique(records, 'bytes')[0] colours = libplot.make_colours() all_x = [] pylab.figure(1).set_size_inches((6.4*scale, 4.8*scale)) pylab.clf() if 'str' in function: # The harness fills out to 16k. Anything past that is an # early match top = 16384 else: top = 2**31 for variant in variants: matches = [x for x in records if x.variant==variant and x.bytes <= top] matches.sort(key=lambda x: x.bytes) X = sorted(list(set([x.bytes for x in matches]))) Y = [] Yerr = [] for xbytes in X: vals = [x.bytes*x.loops/x.elapsed/(1024*1024) for x in matches if x.bytes == xbytes] if len(vals) > 1: mean = sum(vals)/len(vals) Y.append(mean) if len(Yerr) == 0: Yerr = [[], []] err1 = max(vals) - mean assert err1 >= 0 err2 = min(vals) - mean assert err2 <= 0 Yerr[0].append(abs(err2)) Yerr[1].append(err1) else: Y.append(vals[0]) all_x.extend(X) colour = colours.next() if X: pylab.plot(X, Y, c=colour) if len(Yerr) > 0: pylab.errorbar(X, Y, yerr=Yerr, c=colour, label=variant, fmt='o') else: pylab.scatter(X, Y, c=colour, label=variant, edgecolors='none') pylab.legend(loc='upper left', ncol=3, prop={'size': 'small'}) pylab.grid() pylab.title('%(function)s of %(aalignment)s byte aligned blocks' % locals()) pylab.xlabel('Size (B)') pylab.ylabel('Rate (MB/s)') # Figure out how high the range goes top = max(all_x) power = int(round(math.log(max(all_x)) / math.log(2))) pylab.semilogx() pylab.axes().set_xticks([2**x for x in range(0, power+1)]) pylab.axes().set_xticklabels([pretty_kb(2**x) for x in range(0, power+1)]) pylab.xlim(0, top) pylab.ylim(0, pylab.ylim()[1]) return True
def plot(records, function, alignment=None, scale=1): variants = libplot.unique(records, 'variant', prefer='this') records = [x for x in records if x.function == function] if alignment != None: records = [ x for x in records if x.src_alignment == alignment[0] and x.dst_alignment == alignment[1] ] alignments = libplot.unique(records, ('src_alignment', 'dst_alignment')) if len(alignments) != 1: return False if libplot.alignments_equal(alignments): aalignment = alignments[0][0] else: aalignment = "%s:%s" % (alignments[0][0], alignments[0][1]) bytes = libplot.unique(records, 'bytes')[0] colours = libplot.make_colours() all_x = [] pylab.figure(1).set_size_inches((6.4 * scale, 4.8 * scale)) pylab.clf() if 'str' in function: # The harness fills out to 16k. Anything past that is an # early match top = 16384 else: top = 2**31 for variant in variants: matches = [ x for x in records if x.variant == variant and x.bytes <= top ] matches.sort(key=lambda x: x.bytes) X = sorted(list(set([x.bytes for x in matches]))) Y = [] Yerr = [] for xbytes in X: vals = [ x.bytes * x.loops / x.elapsed / (1024 * 1024) for x in matches if x.bytes == xbytes ] if len(vals) > 1: mean = sum(vals) / len(vals) Y.append(mean) if len(Yerr) == 0: Yerr = [[], []] err1 = max(vals) - mean assert err1 >= 0 err2 = min(vals) - mean assert err2 <= 0 Yerr[0].append(abs(err2)) Yerr[1].append(err1) else: Y.append(vals[0]) all_x.extend(X) colour = colours.next() if X: pylab.plot(X, Y, c=colour) if len(Yerr) > 0: pylab.errorbar(X, Y, yerr=Yerr, c=colour, label=variant, fmt='o') else: pylab.scatter(X, Y, c=colour, label=variant, edgecolors='none') pylab.legend(loc='upper left', ncol=3, prop={'size': 'small'}) pylab.grid() pylab.title('%(function)s of %(aalignment)s byte aligned blocks' % locals()) pylab.xlabel('Size (B)') pylab.ylabel('Rate (MB/s)') # Figure out how high the range goes top = max(all_x) power = int(round(math.log(max(all_x)) / math.log(2))) pylab.semilogx() pylab.axes().set_xticks([2**x for x in range(0, power + 1)]) pylab.axes().set_xticklabels( [pretty_kb(2**x) for x in range(0, power + 1)]) pylab.xlim(0, top) pylab.ylim(0, pylab.ylim()[1]) return True