-
Bacon-wrapped closures
Simplifying
Is there any point in simplifying the code you put in before publishing it or does flash do it for you?
example -
unsimplified: x = 4/2
simplified: x = 2
If flash doesn't simplify it, every time the line is run it would have to calculate 4/2, creating a slower runtime - which is what I'm trying to avoid.
Thanks
Neal
-
Bacon-wrapped closures
I decided to write a loop to test it out since nobody here seems to know offhand. It takes the seconds and milliseconds, then runs the line "x = 5+5" a million times, then takes the time again and outputs the difference between the two times.
code:
my_date = new Date();
secs = my_date.getSeconds();
mils = my_date.getMilliseconds();
for(i = 0;i < 1000000;i ++){
x = 5+5;
}
my_date = new Date();
if(secs > my_date.getSeconds()){
secs += 60;
}
trace(my_date.getMilliseconds()-mils+(my_date.getSeconds()-secs)*1000);
That averaged around 5906 milliseconds to complete.
I changed the "x = 5+5" line to "x = 10" and got an average of 5250 milliseconds.
Then for a control, I ran it again with all the code but that one x= line and got an average around 3910.
So if you take 100-(5250-3910)/(5906-3910)*100 there's about a 32% difference between the simplified and unsimplified versions.
Looks like you can speed up slow programs a little if you simplify your equations.
Neal
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|