示例#1
0
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)
示例#2
0
文件: plot-align.py 项目: 0mp/freebsd
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)
示例#3
0
文件: plot-sizes.py 项目: 0mp/freebsd
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
示例#4
0
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