AS3 Benchmark: Graphics.beginBitmapFill() vs BitmapData()
Just worked on a racing game…
It requires lots of graphics and bitmaps. I have just discovered the other way how to render bitmaps in the flash.
Before, I’m using BitmapData and insert it in Bitmap, then add it in the stage. Just a while ago, I tried to use the Graphics.beginBitmapFill(). First, I did some benchmark and this how it was:
- using BitmapData:
var bmpData:BitmapData = new BitmapData(100,100, false, 0x000000); var bmp:BitmapData = new BitmapData(100,100, false, 0x000000); for(var i:int = 0; i < 10000; i++){ bmp.draw(bmpData); } |
- using Graphics.beginBitmapFill()
var bmpData:BitmapData = new BitmapData(100,100, false, 0x000000); var shp:Shape = new Shape(); for(var i:int = 0; i < 10000; i++){ shp.graphics.beginBitmapFill(bmpData); shp.graphics.drawRect(0,0,100,100) } |
This gave me 17ms for Graphics.beginBitmapFill() and 93ms for Bitmapdata()
So I’m suggesting now to use Graphics.beginBitmapFill() for bitmap patterns.
2 Comments to “AS3 Benchmark: Graphics.beginBitmapFill() vs BitmapData()”
RSS feed for comments on this post. TrackBack URI


By Pierre Chamberlain, August 23, 2012 @ 1:55 am
Nice benchmark results! Do you know by anychance if Graphics.beginBitmapFill() would perform better on mobile devices as well? iOS and Android devices?
By Jordan Laine, April 25, 2013 @ 5:59 pm
Why aren’t you using copyPixels instead of draw?