[osflash] AS3 optimizations page created
zwetan
zwetan at gmail.com
Sat Aug 25 23:28:38 PDT 2007
On 8/24/07, John Grden <neoriley at gmail.com> wrote:
> The post on my blog did so well, and the comments were growing and growing
> and samples were being added left and right blah blah blah
>
> So I created a community page where we can add links and more optimization
> techniques with explanations. Probably should break it up into separate
> pages seeing as it's a pretty long page already. If someone feels like
> doing that, be my guest ;)
>
> Also, if you posted a comment out there, and I DIDN'T get your
> change/fix/update in this new page, please make the change an add your
> stuff, I really appreciate the input and your time!
>
> http://osflash.org/as3_speed_optimizations#as3_speed_tests
>
don't want to bring the joy down
but be careful about micro-benchmark
lately that kind of same benchmarks bring some heated comments here
http://blogs.sun.com/chrisoliver/entry/hotspot_vs_adobe_tamarin_vm
and inside those comments this link
http://strongtalk.org/benchmarking.html
could help define better benchmarks
indicating the version of the flash player running those benchmarks
should be included in those tests
flash player being based on the Tamarin VM and seeing
the work the Adobe folk and Mozilla folk putting in Tamarin
I would not be surprise at all if FP10, FP11/AS4, etc..
would bring much more optimized computation ;)
an other interesting way to really compare a full programm speed in AS3
would be to use namespace
for ex:
package test
{
import flash.utils.getTimer;
public class Benchmarks
{
public namespace empty = "empty";
public namespace standard = "standard";
public namespace optimized = "optimized";
public var mode:Namespace;
public function Benchmarks( mode:Namespace = empty )
{
this.mode = mode;
}
public function runAll():void
{
mode = empty;
run();
mode = standard;
run();
mode = optimized;
run();
}
public function run():void
{
var time:int = getTimer();
for(var i:int=0;i<10000000;i++)
{
mode::testDivide( i );
}
trace( "mode: " + mode );
trace( "testDivide: " + (getTimer()-time) );
trace( "--------------" );
}
empty function testDivide( num:int ):void
{
}
standard function testDivide( num:int ):void
{
var local:Number = num/2;
}
optimized function testDivide( num:int ):void
{
var local:Number = num*.5;
}
}
}
//use
import test.Benchmarks;
var t:Benchmarks = new Benchmarks();
t.runAll();
and suprinsingly I obtain
mode: empty
testDivide: 8936
--------------
mode: standard
testDivide: 8974
--------------
mode: optimized
testDivide: 9363
--------------
cheers,
zwetan
More information about the osflash
mailing list