House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  Adobe Flex

a question about code speed of flex

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
CODE 1
harry wang
02/03/10 10:06 P
D=1;
Andrew Scott
02/06/10 03:25 A
>CODE 1
harry wang
02/04/10 10:08 A
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
harry wang
02/03/2010 10:06 PM

CODE 1 function test():void{         var loop:int = 0; var i:int = 0; var j:int = 0; var now:Date = new Date(); var d:Number = 1.1; for(i=0;i<10;i++){ for(j=0;j<10000000;j++){   (d*=1.0000001)>1; } now = new Date(); text.text+=(""+now.getTime()+" "+d+"\n"); } } CODE 2 function test():void{ var loop:int = 0; var i:int = 0; var j:int = 0; var now:Date = new Date(); var d:Number = 1.1; for(i=0;i<10;i++){ for(j=0;j<10000000&&(d*=1.0000001)>1;j++){    } now = new Date(); text.text+=(""+now.getTime()+" "+d+"\n"); } } RESULT 1 1265207560811 2.9901098635452765 1265207562139 8.127960905517952 1265207563374 22.094087340094895 1265207564593 60.05795316514031 1265207565764 163.25443467583585 1265207567061 443.7715412652174 1265207568389 1206.2960569981067 1265207569624 3279.052489441804 1265207570921 8913.38835614975 1265207572124 24229.100401210693 2 1265207634858 2.9901098635452765 1265207634968 8.127960905517952 1265207635077 22.094087340094895 1265207635171 60.05795316514031 1265207635280 163.25443467583585 1265207635374 443.7715412652174 1265207635483 1206.2960569981067 1265207635577 3279.052489441804 1265207635686 8913.38835614975 1265207635780 24229.100401210693 Do anyone know what's the cause.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Barney Boisvert
02/03/2010 10:18 PM

What exactly are you demonstrating?  What I see is that evaluating one compound expression instead of two simpler expressions is about 12 times slower.  Of course, the actual delta is measured in fractional microseconds, so it's most likely due to slight variations in your CPU load at the time of the test, or perhaps the AS VM performing optimizations part way through the first loop.  Did you try the tests in reverse order?  In any case, the difference is WAY too small to care about in pretty much every situation. cheers, barneyb ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
harry wang
02/04/2010 04:42 AM

----- Excess quoted text cut - see Original Post for more ----- I think the difference is very big. It seems AS VM optimization is too bad in the body of a for loop. Here is another test, more simple. static function test(text:TextArea):void{            var loop:int = 0;         var i:int = 0;         var j:int = 0;         var k:int = 0;         var now:Date = new Date();         var d:int = 1;         for(i=0;i<10;i++){           for(j=0;j<10000000;j++){           d=1;   //Comment out this  to see difference                    }           now = new Date();                      text.text+=(""+now.getTime()+" "+d+"\n");         }       } If d=1 is executed it cost 10seconds ,if it not execuetd it cost 1 seconds. Can you try to repeat it on your machine,may be I use some wrong complier options.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Andrew Scott
02/06/2010 03:25 AM

D=1; Takes 10 seconds? Boy I am not sure what or how slow your computer is but that code takes like .00100ms for me to run. ----- Excess quoted text cut - see Original Post for more ----- I think the difference is very big. It seems AS VM optimization is too bad in the body of a for loop. Here is another test, more simple. static function test(text:TextArea):void{            var loop:int = 0;         var i:int = 0;         var j:int = 0;         var k:int = 0;         var now:Date = new Date();         var d:int = 1;         for(i=0;i<10;i++){           for(j=0;j<10000000;j++){           d=1;   //Comment out this  to see difference                    }           now = new Date();                      text.text+=(""+now.getTime()+" "+d+"\n");         }       } If d=1 is executed it cost 10seconds ,if it not execuetd it cost 1 seconds. Can you try to repeat it on your machine,may be I use some wrong complier options.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
harry wang
02/04/2010 10:08 AM

----- Excess quoted text cut - see Original Post for more ----- This is because the test is run under debug mode, after I export the project as release build the problem is gone.


<< Previous Thread Today's Threads Next Thread >>

Search flex

March 21, 2010

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
   1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31