[cairo] Testing Performance SVGSurface/PDFSurface as meta surfaces

Stuart Axon stuaxo2 at yahoo.com
Sun May 9 16:01:53 PDT 2010

> From: Stuart Axon <stuaxo2 at yahoo.com>

> To: cairo at cairographics.org
> Sent: Sun, May 9, 2010 7:09:56 PM
> Subject: Testing Performance SVGSurface/PDFSurface as meta surfaces
> I thought I'd test my app with SVGSurfaces vs PDFSurfaces as meta surface 
> standins.

SVGSurface is seems much quicker:

Draw 1000 
> frames:
SVGSurface:  1m28
PDFSurface:  1m48

Running a few 
> times, the wallclock time is the same to within a couple of seconds.
It might 
> be down to the nature of my app (shoebot running a bot that 
animates a lot 
> of circles)

Note:  I'm aiming for 60fps, so quite a long way to 
> go.

Another quick note:  In windows SVGSurface(None, w, 
> h)  says it's missing a file object, so I have to pass in 'nul'

> S++

I managed to get the time down to about 50 seconds wall clock time by caching the SVGSurfaces and calling create_similar whenever a surface is needed, like this:

svg_surfaces = {}
def RecordingSurface(*size):
    if os.name == 'nt':
        fobj = 'nul'
        fobj = None
    svg_surface = svg_surfaces.setdefault(size, cairo.SVGSurface(fobj, *size))
    return svg_surface.create_similar(cairo.CONTENT_COLOR_ALPHA, *size)


More information about the cairo mailing list