Archive for Performance

BitmapData.lock benchmark

Well, I don’t know if anybody read the Thomas Pfeiffer aka Kiroukou (the Sandy3D creator and project leader) commented on my previous post.
Here’s what he said.

Indeed Sandy does a clone of the original texture, for few reasons:
- avoid an unfortunate dispose call.
- allowing to have a setTransparency method to dynamically change the transparency without changing the original bitmapdata of the user.

Concerning the lock() and unclock() are you sure it has a performance impact?
as far I know, this can’t provide any performance boost since the bitmapdata isn’t attached to the flash display list. When the object is out of stage, there’s no advantage to lock it.
But I’d be interessted to have your feedback about that, and your performance test.

About the BitmapData.clone(), he got his point.
It just don’t work for me because I’m using too many 3d Objects with different BitmapMaterial for each, so, the system memory gets too high.
But, about the setTransparency method, he is right.

About the lock and unlock methods, I runned a little benchmark test, because I got curious too how much performance boost you can get.
Here’s the two test I made. (Clicking on the flash area it will re-run the benchmark test)

Using the lock and unlock methods.

Not using the lock and unlock methods.

It’s a really simple test, just to make a benchmark test.
Actually, it’s not a situation that uses any 3d framework.

Creating a BitmapData.
Creating 1000 Bitmaps.
Applying 1000 times a BlurFilter over the BitmapData.

On my PC I get about 150ms faster with locking the BitmapData.

keita

Comments (2)

BitmapMaterial tips

I was making some experiments with Sandy3d and Papervision3d and I realized some tips to increase the performance.

Firstly, with Sandy3d 3.0, when you create a BitmapMaterial, the BitmapData that you used to create the Material, is cloned to create the BitmapMaterial.texture.
So, one think you can do is dispose the BitmapData that you used to create the Material after instantiating it and also, if you want to update your BitmapData use the BitmapMaterial.texture directly.

Something like this:

var bmpData:BitmapData = new BitmapData(100, 100, true, 0×00000000);
var bmpMaterial:BitmapMaterial = new BitmapMaterial(bmpData);

bmpData.dispose();

bmpMaterial.texture.fillRect(new Rectangle(10,10,30,30), 0xffff0000);

This will not work with Papervision3d because it uses the same BitmapData instance (in my opinion, smarter).

Now for both, Sandy3d and Papervision3d.
As you make changes on your BitmapData, it’s updated on every poligon.
So, use the BitmapData.lock() and BitmapData.unlock() when you are redrawing your BitmapData texture.

var bmpData:BitmapData = new BitmapData(100, 100, false, 0×00000000);
var bmpMaterial:BitmapMaterial = new BitmapMaterial(bmpData);

redrawBitmap();

function redrawBitmap(){

bmpData.lock();

bmpData.fillRect(bmpData.rect, 0×00000000);
bmpData.fillRect(new Rectangle(10,10,30,30), 0xffff0000);

var blurFilter:BlurFilter = new BlurFilter(16, 16, 3);

bmpData.applyFilter(bmpData, bmpData.rect, new Point(0,0), blurFilter);

bmpData.unlock();

}

Comments (2)

BitmapData.draw x Graphics.beginBitmapFill

Firstly… sorry for my poor English…

Working on Recyou.jp, I had to use many BitmapDatas, and so, I had to work out some way to make it lighter.
One thing I realized is that using Graphics.beginBitmapFill besides BitmapData.draw its much faster.

I made the benchmarks, drawing 10000 bitmapDatas, one using BitmapData.draw, and other using Graphics.beginBitmapFill.

First the benchmark with BitmapData.draw (Clicking on the flash it will re-run the benchmark):


The code is something like this:

var genericBmp:BitmapData = new BitmapData(100,100, false, 0×000000);
var bmp:BitmapData = new BitmapData(100,100, false, 0×000000);
for(var i = 0; i < 10000; i++){
bmp.draw(genericBmp);
}

Now the benchmark with Graphics.beginBitmapFill (Clicking on the flash it will re-run the benchmark):


The code is something like this:

var genericBmp:BitmapData = new BitmapData(100,100, false, 0×000000);
var bmp:BitmapData = new BitmapData(100,100, false, 0×000000);
for(var i = 0; i < 10000; i++){
graphics.beginBitmapFill(genericBmp);
graphics.drawRect(0,0,100,100);
}

So, if you are trying to create some bitmap pattens or attaching a Bitmap child and redrawing it’s BitmapData, try using the Graphics.beginBitmapFill.

Comments (6)

Launching my public subversion

http://code.hellokeita.in/public/

People, I’m launching my codes on public subversion repository.
It’s almost nothing there… but, how people claimed for the source (here), there is it.

Hope you enjoy it…

PS: If there’s any bug or anything I forgot, apologize me… I still don’t get much time to review my codes…

Comments (5)

Performance increase with BitmapData

I’m working on a project that everything eats performance, using FLV videos, animated smooth Bitmaps, Papervision3D and everything else…
So I started desperately find a way to increase the flash performance.

So, I realized that using BitmapDatas instead using many sprites and FLV videos helped really much.
I mean, instead adding a full screen FLV streaming video on your background, add a Bitmap child on your background that draws the FLV child.

I didn’t make any benchmarks, but, at least on this project it’s helping me speeding up my heavy processing flash.

Comments (2)