Re: HTML5 canvas: Performance on context access.

Boris Zbarsky <[email protected]> Tue, 19 Jan 2010 01:06:15 -0500
Newsgroups gmane.comp.mozilla.performance
Message-ID <[email protected]>
On 1/18/10 7:38 AM, davidcm wrote:
> I've found some quite of strange behavior when updating the canvas
> inside a loop. First canvas access after a screen update (e.g., when
> the CPU gets idle) has an extremely high cost, even if just putting a
> pixel onto the screen. An example that shows this behavior is below,
> you can profile consumed timings with the Firebug profiler. In the
> code I'm working right now, first access takes the 23% of the loop
> time, and the update of about 50 images -with slicing, rotations, etc-
> just take a 15%).

I'd be interested in seeing your actual loop...  As well as which OS 
you're on and what Gecko version.  I just tried your testcase on Mac 
with a mozilla-central build, and the multiple fills take more time than 
the one fill, as expected...

> Check the performance of this example with the firebug profiler; you
> will see that f1() takes more time to run that f2()... and

Note that the firebug profiler perturbs the results enough (e.g. by 
disabling the jit when active) that its information may or may not match 
what you're doing well.

Do timings using JS Date() show the same effect?

-Boris