Пример #1
0
def benchmark_draw_path_flags(cycles=10, n_pts=1000, sz=(1000, 1000)):
    print('realtime:', end=' ')
    width, height = sz
    pts = zeros((n_pts, 2), Float)
    x = pts[:, 0]
    y = pts[:, 1]
    interval = width / float(n_pts)
    x[:] = arange(0, width, interval)

    flags = [
        kiva.FILL, kiva.EOF_FILL, kiva.STROKE, kiva.FILL_STROKE,
        kiva.EOF_FILL_STROKE
    ]

    for flag in flags:
        t1 = time.clock()
        for i in range(cycles):
            gc = agg.GraphicsContextBitmap(sz)
            y[:] = height / 2. + height / 2. * sin(x * 2 * pi / width +
                                                   i * interval)
            gc.lines(pts)
            gc.draw_path(flag)

        t2 = time.clock()
        agg.write_bmp_rgb24("draw_path%d.bmp" % flag, gc.bitmap)
        tot_time = t2 - t1
        print('tot,per cycle:', tot_time, tot_time / cycles)
    return
Пример #2
0
def benchmark_compiled_path(cycles=10, n_pts=1000, sz=(1000, 1000)):
    """ Render a sin wave to a compiled_path then display it repeatedly.
    """
    width, height = sz
    pts = zeros((n_pts, 2), Float)
    x = pts[:, 0]
    y = pts[:, 1]
    interval = width / float(n_pts)
    x[:] = arange(0, width, interval)
    y[:] = height / 2. + height / 2. * sin(x * 2 * pi / n_pts)
    path = agg.CompiledPath()
    path.lines(pts)
    #path.move_to(pts[0,0],pts[0,1])
    #for x,y in pts[1:]:
    #    path.line_to(x,y)

    t1 = time.clock()
    gc = agg.GraphicsContextBitmap(sz)
    for i in range(cycles):
        #gc.clear()
        gc.add_path(path)
        gc.stroke_path()
    t2 = time.clock()

    tot_time = t2 - t1
    print('tot,per cycle:', tot_time, tot_time / cycles)
    return
Пример #3
0
def benchmark_draw_path_flags(cycles=10, n_pts=1000, sz=(1000, 1000)):
    print("realtime:", end=" ")
    width, height = sz
    pts = zeros((n_pts, 2), float)
    x = pts[:, 0]
    y = pts[:, 1]
    interval = width / float(n_pts)
    x[:] = arange(0, width, interval)

    flags = [
        kiva.FILL,
        kiva.EOF_FILL,
        kiva.STROKE,
        kiva.FILL_STROKE,
        kiva.EOF_FILL_STROKE,
    ]

    for flag in flags:
        t1 = perf_counter()
        for i in range(cycles):
            # TODO: module 'kiva.agg' has no attribute 'GraphicsContextBitmap'
            gc = agg.GraphicsContextBitmap(sz)
            y[:] = height / 2.0 + height / 2.0 * sin(x * 2 * pi / width +
                                                     i * interval)
            gc.lines(pts)
            gc.draw_path(flag)

        t2 = perf_counter()
        agg.write_bmp_rgb24("draw_path%d.bmp" % flag, gc.bitmap)
        tot_time = t2 - t1
        print("tot,per cycle:", tot_time, tot_time / cycles)
    return
Пример #4
0
def benchmark_real_time(cycles=10, n_pts=1000, sz=(1000, 1000)):
    """ Render a sin wave to the screen repeatedly.  Clears
        the screen between each rendering.
    """
    print('realtime:', end=' ')
    width, height = sz
    pts = zeros((n_pts, 2), Float)
    x = pts[:, 0]
    y = pts[:, 1]
    interval = width / float(n_pts)
    x[:] = arange(0, width, interval)
    t1 = time.clock()
    gc = agg.GraphicsContextBitmap(sz)
    for i in range(cycles):
        y[:] = height / 2. + height / 2. * sin(x * 2 * pi / width +
                                               i * interval)
        #gc.clear()
        gc.lines(pts)
        gc.stroke_path()
        #agg.write_bmp_rgb24("sin%d.bmp" % i,gc.bitmap)
    t2 = time.clock()
    tot_time = t2 - t1
    print('tot,per cycle:', tot_time, tot_time / cycles)
    return
Пример #5
0
def benchmark_real_time(cycles=10, n_pts=1000, sz=(1000, 1000)):
    """ Render a sin wave to the screen repeatedly.  Clears
        the screen between each rendering.
    """
    print("realtime:", end=" ")
    width, height = sz
    pts = zeros((n_pts, 2), float)
    x = pts[:, 0]
    y = pts[:, 1]
    interval = width / float(n_pts)
    x[:] = arange(0, width, interval)
    t1 = perf_counter()
    # TODO: module 'kiva.agg' has no attribute 'GraphicsContextBitmap'
    gc = agg.GraphicsContextBitmap(sz)
    for i in range(cycles):
        y[:] = height / 2.0 + height / 2.0 * sin(x * 2 * pi / width +
                                                 i * interval)
        # gc.clear()
        gc.lines(pts)
        gc.stroke_path()
        # agg.write_bmp_rgb24("sin%d.bmp" % i,gc.bitmap)
    t2 = perf_counter()
    tot_time = t2 - t1
    print("tot,per cycle:", tot_time, tot_time / cycles)