Charles, I'm using Number, as I could read int or uint are casted
internally to perform math operations.

The machine :
- P4 2.4Ghz
- Win XP Pro sp2
- 1.5 Ghz RAM

The code (sorry trace are in french) :

public final function testBasics():void
        {
            var iteration:uint = 100000;
            var a:Number;
            var t:uint;
           
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                a = 5+12;
            }
            trace("addition (5+12) : "+(getTimer()-t)+" ms");
           
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                a = 5-12;
            }
            trace("soustraction (5-12) : "+(getTimer()-t)+" ms");
           
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                a = 5*12;
            }
            trace("multiplication (5x12) : "+(getTimer()-t)+" ms");
           
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                a = 5/12;
            }
            trace("division (5/12) : "+(getTimer()-t)+" ms");
           
            var s:String;
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                s += "a";
            }
            trace("concaténation : "+(getTimer()-t)+" ms");
           
           
            var sb:String = new String("");
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                sb.concat("a");
            }
            trace("concaténation avec String.concat : "+(getTimer()-t)+"
ms");
           
           
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                a = Math.round(16.87956);
            }
            trace("arrondi (16.87956) : "+(getTimer()-t)+" ms");

            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                a = Math.sqrt(2);
            }
            trace("carré (2) : "+(getTimer()-t)+" ms");
           
            var o:Object;
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                o = {x:50,y:100};
            }
            trace("instanciations d'objets {x:50,y:100} :
"+(getTimer()-t)+" ms");
           
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                o = new Object();
            }
            trace("instanciations d'objets avec new : "+(getTimer()-t)+"
ms");
           
            var ar:Array;
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                ar = [50,60,70];
            }
            trace("instanciations de tableaux [50,60,70] :
"+(getTimer()-t)+" ms");
           
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                ar = new Array(50,60,70);
            }
            trace("instanciations de tableaux avec new :
"+(getTimer()-t)+" ms");
}

Another bench on a simple string research, to compare old strings
methods and RegExp  :

public final function testSearch():void
        {
            var originalString:String = "she sells seashells at the
seashore.";
            var searchString:String = "sh";
            var searchPattern:RegExp = /sh/;
            var iteration:uint = 100000;
            var t:uint;
            var b:Boolean;
           
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                b = (originalString.search(searchString) != -1);
            }
            trace("String.search avec une String : "+(getTimer()-t)+" ms");
           
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                b = (originalString.search(searchPattern) != -1);
            }
            trace("String.search avec une RegExp : "+(getTimer()-t)+" ms");
           
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                b = (originalString.match(searchString) != null);
            }
            trace("String.match avec une String : "+(getTimer()-t)+" ms");
           
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                b = (originalString.match(searchPattern) != null);
            }
            trace("String.match avec une RegExp : "+(getTimer()-t)+" ms");
           
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                b = (originalString.indexOf(searchString) != -1);
            }
            trace("String.indexOf : "+(getTimer()-t)+" ms");
           
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                b = (originalString.lastIndexOf(searchString) != -1);
            }
            trace("String.lastIndexOf : "+(getTimer()-t)+" ms");
           
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                b = (searchPattern.exec(originalString) != null);
            }
            trace("RegExp.exec : "+(getTimer()-t)+" ms");
           
            t = getTimer();
            for(var i:uint=0;i<iteration;i++)
            {
                b = searchPattern.test(originalString);
            }
            trace("RegExp.test : "+(getTimer()-t)+" ms");
        }

And the results :

String.search avec une RegExp : 560 ms
String.match avec une String : 886 ms
String.match avec une RegExp : 562 ms
String.indexOf : 9 ms
String.lastIndexOf : 11 ms
RegExp.exec : 581 ms
RegExp.test : 574 ms



Charles Parcell wrote:
> Could you supply the code you tested with please.
>
> Charles P.
>
>
> On 7/10/06, Cédric Néhémie <[EMAIL PROTECTED]> wrote:
>>
>> Hi,
>>
>> Here some benchs I've made during the Beta 2, comparison between AS2's
>> and AS3's basics operations.
>>
>> All have been mades on 100000 iterations.
>> ____________________________________________________________
>> AS2:
>>
>> addition (5+12) : 370 ms
>> subtract (5-12) : 365 ms
>> multiply (5x12) : 351 ms
>> divide (5/12) : 375 ms
>> concat : 471 ms
>> round (16.87956) : 346 ms
>> square (2) : 395 ms
>> creating objects with {x:50,y:100} : 1560 ms
>> creating objects with new : 1734 ms
>> creating arrays with [50,60,70] : 1834 ms
>> creating arrays with new : 2127 ms
>> ____________________________________________________________
>> AS3 :
>>
>> addition (5+12) : 4 ms
>> subtract (5-12) : 6 ms
>> multiply (5x12) : 6 ms
>> divide (5/12) : 7 ms
>> concat : 63 ms
>> concat with StringBuilder : 12 ms
>> round (16.87956) : 25 ms
>> square (2) : 24 ms
>> creating objects with {x:50,y:100} : 89 ms
>> creating objects with new : 70 ms
>> creating arrays with [50,60,70] : 90 ms
>> creating arrays with new : 300 ms
>>
>> Something cool is that the new keyword is much faster on AS3 when
>> creating objects, whereas it's the inverse in AS3.
>>
>>
>>
>> Cédric
>>
>> Andreas Rønning wrote:
>> > Hardly benchmarks, but you can get a quick comparison in
>> flashplayer 9:
>> >
>> > http://andreas.rayon.no/AS2.swf
>> >
>> > Press the 3-key on your keyboard to load the most complex system,
>> > observe the BREAKNECK SPEED at which Flash player 8 handles it.
>> >
>> > http://andreas.rayon.no/AS3.swf
>> >
>> > I rest my case :)
>> >
>> > - Andreas
>> >
>> >
>> > Nick Weekes wrote:
>> >> Andreas, you got any links to your benchmarking?  Id be interested to
>> >> see
>> >> them (Im not planning on migrating to AS3 just yet).
>> >>
>> >> -----Original Message-----
>> >> From: [EMAIL PROTECTED]
>> >> [mailto:[EMAIL PROTECTED] On Behalf Of
>> Andreas
>> >> Rønning
>> >> Sent: 10 July 2006 14:59
>> >> To: Flashcoders mailing list
>> >> Subject: Re: [Flashcoders] AS3 faster ??
>> >>
>> >> I did an l-system implementation in AS2 recently. In FP8 i could only
>> do
>> >> simple systems with a couple of recursions before the player choked,
>> and
>> >> playback was slow as well (i animated the growth with perlin noise
>> for
>> a
>> >> wind effect). Porting to AS3 let me quadruple the l-system
>> >> complexity, still
>> >> get instantaneous results and far, far better playback speed.
>> >>
>> >> Not hard numbers, i know, but pretty mindblowing for me to watch as a
>> >> developer.
>> >>
>> >> AS3 doesn't wrap AS2, this is important to remember. AS2 was pretty
>> much
>> >> AS1 with knobs on, AS3 is a new language to learn (albeit not a tough
>> >> one to
>> >> learn if you're used to AS2).
>> >>
>> >> - Andreas
>> >>
>> >> neo binedell wrote:
>> >>
>> >>> Of course it will be faster only if you port the code over to AS3
>> >>> (otherwise it will still use the old AS2/1 VM1).
>> >>>
>> >>> I posted about the 3D engine I wrote and the speed increase I got
>> >>> when I converted it to AS3 a few days ago so you can check that out
>> >>> as an example of just how much faster it is ;p
>> >>>
>> >>> ~neo
>> >>>
>> >>> -----Original Message-----
>> >>> From: [EMAIL PROTECTED]
>> >>> [mailto:[EMAIL PROTECTED] On Behalf Of
>> >>> Patrick Matte
>> >>> Sent: 06 July 2006 05:47 PM
>> >>> To: Flashcoders mailing list
>> >>> Subject: [Flashcoders] AS3 faster ??
>> >>>
>> >>> Hi people, they say that AS3 is 10 times faster than AS2 but what
>> >>> does that really means ? Does that mean that my movies will play
>> >>> faster even if I have a few dozens movieclips with graphics flying
>> >>> all over the screen? Or does it just mean that my .swf will be
>> >>> compiling 10 times
>> >>
>> >> faster?
>> >>
>> >>>
>> >>> _______________________________________________
>> >>> Flashcoders@chattyfig.figleaf.com
>> >>> To change your subscription options or search the archive:
>> >>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> >>>
>> >>> Brought to you by Fig Leaf Software
>> >>> Premier Authorized Adobe Consulting and Training
>> >>> http://www.figleaf.com http://training.figleaf.com
>> >>>
>> >>> _______________________________________________
>> >>> Flashcoders@chattyfig.figleaf.com
>> >>> To change your subscription options or search the archive:
>> >>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> >>>
>> >>> Brought to you by Fig Leaf Software
>> >>> Premier Authorized Adobe Consulting and Training
>> >>> http://www.figleaf.com http://training.figleaf.com
>> >>
>> >>
>> >
>>
>> _______________________________________________
>> Flashcoders@chattyfig.figleaf.com
>> To change your subscription options or search the archive:
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>> Brought to you by Fig Leaf Software
>> Premier Authorized Adobe Consulting and Training
>> http://www.figleaf.com
>> http://training.figleaf.com
>>
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
>

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to