Bigpants' HTML5 CANVAS PERFORMANCE SPECTACULAR - cows did come home
Home   Test   iPad Notes     back to bigpants
Technical Details >

Does canvas size impact performance?
1024x644 canvas     1 fillRect      
800x600 canvas     1 fillRect      
400x300 canvas     1 fillRect      
Conclusion: No.
no details

Do fillRect and drawImage have same performance?
800x600 canvas     300 fillRect      
800x600 canvas     300 drawImage - no transparency      
800x600 canvas     300 drawImage - transparency      
Conclusion: Overall: fillRect performs slightly better than drawImage. drawImage + transparent = drawImage + notransparent.
no details

Lots of Small Things or A Few Big Things?
1024x644 canvas     1,000 fillRect - 40 x 20 = 800,000      
1024x644 canvas     250 fillRect - 80x40 = 800,000      
1024x644 canvas     1,000 drawImage - 40 x 20 = 800,000      
1024x644 canvas     250 drawImage - 80x40 = 800,000      
Conclusion: Overall: Few Big Things performs significantly better than Lots of Small Things.
presumably caused by the overhead in making the call

"Dirtying" 1: Small Canvas vs. Changing same-size small section of Large Canvas (Regions)
400x300 canvas     300 fillRect      
1024x644 canvas     300 fillRect - staying within 400x300      
Conclusion: Overall: Make the canvas as small as possible. Extra unused space can severely impact performance.
WinXP Chrome 18.0.1025.152m - little difference
WinXP FireFox 3.6.28 - bigger unused canvas runs at half the speed
iPad 1 v5.1 - bigger unused canvas runs at half the speed
iPad 2 v5.1 - no difference

"Dirtying" 2: Rectangles drawn across Canvas vs. Rectangles drawn on top of each other (Regions)
1024x644 canvas     12 fillRect - 200x150 - random placement      
1024x644 canvas     12 fillRect - 200x150 - directly on top of each other      
1024x644 canvas     12 drawImage - 200x150 - random placement      
1024x644 canvas     12 drawImage - 200x150 - directly on top of each other      
Conclusion: Overall: Messing up the canvas via random placement impacts performance significantly more than messing up the same spot.
WinXP Chrome 18.0.1025.152m - fillRect/drawImage drawn across Canvas 3fps slower (23fps vs. 26fps)
WinXP FireFox 3.6.28 - no difference

Other Optimizations
1024x644 canvas     1,000 fillRect      
1024x644 canvas     1,000 fillRect     One Color (1 .fillStyle call / less state change)      
1024x644 offscreen canvas     1,000 fillRect     drawImage'd ONCE to 1024x644     (Double Buffer)      
1024x644 canvas     1,000 fillRect     'Paged' Double Buffer (2 canvases: render on background canvas, zIndex it to foreground, repeat)      
Conclusion: Overall: Don't need these other optimizations, just draw on the canvas.

Ke Zhendong wearing a Gucci suit unveiled in 2012 the 49th Taiwan nike free trainer Golden Horse Awards red carpet _ Ke Zhendong .11 evening of May 24, 2012 49th Taiwan Golden Horse Awards Ceremony at the very local cultural characteristics of Taiwan's Ilan cultural workshops organized. Ke Zhendong dressed in Gucci unveiled Awards red carpet.Joke dressed in Gucci green dress 2013 early spring vacation series debut in 2012 49th Taiwan Golden Horse Awards Michael Kors Shoulder Bags red carpet evening of Michael Kors Clutches 24 .11 _ Joke, 2012 49th Taiwan Golden Horse Awards Ceremony at very local culture chemical characteristics nike free run 5.0 womens of the field Ilan Luo Dongwen organized. Joke dressed in Gucci 2013 early spring vacation series debut ceremony red carpet green dress. Unsurprisingly Gucci once again chosen to do ""armor"" of Lilao, even after the hair is always super docile comb hair, Michael Kors Satchels always sophisticated and elegant, but it is no nike free 4.0 surprise there is no error.Andy debut 2012 49th Taiwan Golden Horse Awards red carpet _ Andy evening of 24 .11, 2012 49th Taiwan Golden nike free 5.0 womens Canada Horse Awards Ceremony at the very local cultural characteristics of the chemical field Ilan Luo Dongwen organized. Andy Awards red carpet debut.Button Chengze Liang phase 2012 49th Taiwan Golden Horse Awards red carpet evening of Nike Free 3.0 V2 May 24, .11, 2012 49th Taiwan Golden Horse Awards Ceremony at the very local cultural characteristics of the chemical field Ilan Luo Dongwen organized. Button Chengze Liang phase Awards red carpet.Eddie nike free 5.0 wearing a Gucci suit unveiled in 2012 the 49th Taiwan Golden Horse Awards red carpet _ Eddie .11 evening of May 24, 2012 49th Taiwan Golden Horse Awards Ceremony at nike free 5.0 the very local cultural characteristics of Taiwan's Ilan cultural workshops organized. nike Canada store Eddie wearing a Gucci suit debut Michael Kors Totes Awards nike air max Canada red carpet.Richie debut in 2012 49th Taiwan Golden Horse Awards red carpet evening of 24 .11 _ Richie, 2012 49th Taiwan Golden Horse Awards Ceremony at very local cultural characteristics of organized Ilan Luo Dongwen chemical field. Richie debut Awards red carpet. Denise, Richie Alec debut 2012 49th Taiwan Golden Horse Awards red carpet evening of .11 _ Alec 24, 2012 49th Taiwan Golden Horse Awards Ceremony at the very local cultural characteristics of the chemical field Ilan Luo Dongwen organized. Alec debut Awards red carpet.Sonia dressed in light blue + black Lanvin shoulder dress hit the color debut nike free 5.0 Canada in 2012 49th Taiwan Golden Horse Awards red carpet _ Sonia evening of 24 .11, 2012 49th Taiwan Golden Horse Nike Air Max 95 awards ceremony held at the very local cultural characteristics Ilan Luo Dongwen chemical field. Sonia dressed in light blue + black Lanvin shoulder dress hit the color ceremony red carpet appearances.Nicholas debut 2012 49th Taiwan Golden Horse Awards red carpet evening of 24 .11 _ Nicholas, 2012 49th Taiwan Golden Horse Awards Ceremony at very local cultural Michael Kors Backpacks characteristics of organized Ilan Luo Dongwen chemical field. Nicholas Awards red carpet debut Angelababy dressed nike free 5.0 Canada Allie Saab 2012 Winter gold sequined skirt debut 2012 49th Taiwan Golden Horse Awards red carpet evening _.11 May 24, 2012 49th Taiwan Golden Horse Awards Ceremony at the very local cultural characteristics Taiwan Ilan Luo Dongwen chemical field organizing. Angelababy dressed Allie Saab 2012 Winter gold sequined dress red carpet debut ceremony, the choice of the perfect combination beginning Awards red carpet,Nike Roshe Run but compared to the last time the unique style side comb long hair, comb the ponytail low it seems a little old-fashioned.Zhang Zixuan debut in 2012 wearing a dress Bra 49th Taiwan Golden Horse Awards red carpet _ Zhang Zixuan .11 evening of January 24, 2012 49th Taiwan Golden Horse Awards Ceremony at the very local cultural characteristics of Yilan, Taiwan Luo Dongwen chemical field organizing. Zhang Zixuan Strapless dress dressed red carpet debut ceremony.Michelle Obama wore Salim Khan nike air max 2013 Neuilly-coming designer dress dinner Prime Minister Manmohan Singh couple _ .11 24 evening, U.S. President Barack Obama and his wife Michelle Obama at the White House South Lawn set up a grand banquet, dinner visiting Washington, Prime Minister Manmohan Singh couple. nike free 3.0 First Lady Michelle Obama chose an Indian by the budding designers Neuilly Salim Khan designed dress, elegant and dignified.2 members dressed in a gray woolen jacket combination debut ""Dream"" charity ambassador took office conference _.11 May 25, two members dressed in a gray woolen jacket combination attended the ""Dream"" charity ambassador took office conference .
Scaling 1 Image
256x161 canvas     1 drawImage - 250x150      
512x322 canvas     1 drawImage - 500x300      
512x322 canvas     1 drawImage - 250x150 scaled to 500x300 (2X larger)      
1024x644 canvas     1 drawImage - 1000x600      
1024x644 canvas     1 drawImage - 500x300 scaled to 1000x600 (2X larger)      
1024x644 canvas     1 drawImage - 250x150 scaled to 1000x600 (4X larger)      
256x161 offscreen canvas     1 drawImage - 250x150     drawImage'd ONCE to 1024x644 (4X larger)      
Conclusion: Overall: Scaling (software) severely impacts performance - best avoided.

Scaling Images
1024x644 canvas     250 drawImage (3 arguments) - 80x40      
1024x644 canvas     250 drawImage (5 arguments - 1:1 scale) - 80x40      
1024x644 canvas     250 drawImage - each 20x10 scaled to 80x40 (4X larger)      
256x161 offscreen canvas     250 drawImage - 20x10     drawImage'd ONCE to 1024x644 (4X larger)      
- - - -
1020x640 canvas     10 drawImage - 400x200      
1020x640 canvas     10 drawImage - each 40x20 scaled to 400x200 (10X larger)      
102x64 offscreen canvas     10 drawImage - 40x20     drawImage'd ONCE to 1020x640 (10X larger)      
Conclusion: Overall: Scaling (software) significantly impacts performance - best avoided.

Size Performance
1024x644 canvas     25 fillRect - (50% canvas) 512x322      
800x600 canvas     25 fillRect - (50% canvas) 400x300      
400x300 canvas     25 fillRect - (50% canvas) 200x150      
- - - -
1024x644 canvas     25 drawImage - (50% canvas) 512x322      
800x600 canvas     25 drawImage - (50% canvas) 400x300      
400x300 canvas     25 drawImage - (50% canvas) 200x150      
Conclusion: Overall: Smaller is faster. Surprise Surprise.
no details

Number of Images
1024x644 canvas     1,000 drawImage - 80 x 40      
800x600 canvas     1,000 drawImage      
400x300 canvas     1,000 drawImage      
- - - -
1024x644 canvas     500 drawImage - 80x40      
800x600 canvas     500 drawImage      
400x300 canvas     500 drawImage      
Conclusion: Overall: Canvas size (and how much you dirty canvas) impacts performance more than the number of images
no details

Rotating Images
1024x644 canvas     1,000 drawImage transparent - 40 x 20 - rotating      
1024x644 offscreen canvas     1,000 drawImage transparent - 40 x 20 - rotating     drawImage'd ONCE to 1024x644      
1024x644 canvas     1,000 drawImage transparent - each 10 x 5 scaled to 40 x 20 (4X larger) - rotating      
256x161 offscreen canvas     1,000 drawImage transparent - 10 x 5 - rotating     drawImage'd ONCE to 1024x644 (4X larger)      
800x600 canvas     1,000 drawImage transparent - 40 x 20 - rotating      
400x300 canvas     1,000 drawImage transparent - 40 x 20 - rotating      
- - - -
1024x644 canvas     250 drawImage transparent - 80 x 40 - rotating      
1024x644 offscreen canvas     250 drawImage transparent - 80 x 40 - rotating     drawImage'd ONCE to 1024x644      
1024x644 canvas     250 drawImage transparent - each 20 x 10 scaled to 80 x 40 (4X larger) - rotating      
256x161 offscreen canvas     250 drawImage transparent - 20 x 10 - rotating     drawImage'd ONCE to 1024x644 (4X larger)      
800x600 canvas     250 drawImage transparent - 80 x 40 - rotating      
400x300 canvas     250 drawImage transparent - 80 x 40 - rotating      
Conclusion: Overall: Software rotation HUGE performance hit. Drawing on a SMALL offscreen buffer helps somewhat.
no details

iPad 3 Retina
2048x1412 canvas     1000 drawImage - 80x40      
2048x1412 canvas     1000 drawImage - 80x40      
2048x1536 canvas     1000 drawImage - 80x40      
2048x1536 canvas     1000 drawImage - 80x40      


Canvas + Body.Background + Canvas.Background
1024x644 canvas     500 fillRect - 40x20      
1024x644 canvas     500 fillRect + body.background=red      
1024x644 canvas     500 fillRect + canvas.background=blue      
1024x644 canvas     500 fillRect + body.background=red + canvas.background=blue      
- - - -
1024x644 canvas     500 fillRect + body.background=repeating40x20image      
1024x644 canvas     500 fillRect + canvas.background=repeating40x20image      
1024x644 canvas     500 fillRect + body.background=repeating40x20image + canvas.background=repeatingimage      
- - - -
1024x644 canvas     500 fillRect + body.background=repeating1000x600image      
1024x644 canvas     500 fillRect + canvas.background=repeating1000x600image      
1024x644 canvas     500 fillRect + body.background=repeatingimage + canvas.background=repeating1000x600image      


























Background
1024x644 canvas     1,000 fillRect      
1024x644 canvas     1,000 fillRect + document.body.style.background=image      
1024x644 canvas     1,000 fillRect + background div.style.background=image      
1024x644 canvas     1,000 fillRect + background canvas      
1024x644 canvas     1000 drawImage + background canvas      
1024x644 canvas     1,000 fillRect + moving background canvas      
1024x644 canvas     1000 drawImage + moving background canvas      
1024x644 canvas     1,000 fillRect + moving background canvas + moving foreground canvas      
1024x644 canvas     1000 drawImage + moving background canvas + moving foreground canvas      

Do rects/images overlapping affect performance?
1024x644 canvas     750 fillRect - no overlap      
1024x644 canvas     750 fillRect - cascading      
1024x644 canvas     750 fillRect - ALL perfectly overlap      
1024x644 canvas     750 drawImage - no overlap, all moving down      
1024x644 canvas     750 drawImage - cascading      
1024x644 canvas     750 drawImage - ALL perfectly overlap      
Conclusion: No (results ARE MISLEADING). Difference caused by dirtying MORE canvas.
I find this result strange.