-
Hype over content...
Pred:
Sorry mate, I meant an actual Flash register as opposed to a "real" CPU one.
I think the look-up time is greatly improved if a variable is declared as opposed to just shoved in there.
I really need to read up on the swf file format and fire up FLASM. joy.
AJ:
A while loop is quicker than a for loop, the example loop you posted wasn't formed as well as it could have been, eg
PHP Code:
var i=(10/2)+1; //Just for examples sake
while (--i){
doSomeThing();
doSomeThing();
}
Squize.
-
This get's more and more strange. Decaliring gobal varable as _global also seems to have a speed impact,
Code:
_global.MAX_VALUE = 39999;
This must work in a similar way to the var for localised variables on a global level. So:
Code:
_global.MAX_VALUE = 39999;
function loop() {
var z;
for (z=0; z<MAX_VALUE; z++) {
z += 1;
}
}
loop();
Results in about 6%-8% increase over the fastest for loop method:
1936 ms
1917 ms
1932 ms
1923 ms
1946 ms
I hope this helps someone!!!
RipX
-
Senior Member
Originally posted by RipX
I hope this helps someone!!!
RipX
Actually, yeah.
-
Hype over content...
RipX could you post your timer code here so if anyone wants to test something they are doing it on an equal footing ?
If you remember I asked about _global in the retro game thread and what sort of performance impact it may have. It'd be nice to have a definitive answer.
I think the most important test would be using a global variable from within an mc. In theory it would eliminate all the _parent / _root ( And all the work-arounds ) calls. Now that would be cool.
Squize.
-
Sure, just a simple timer and trace:
Code:
_global.MAX_VALUE = 39999;
function loop() {
var z;
var ms = getTimer();
trace("start test");
for (z=0; z<MAX_VALUE; z += 10) {
z += 1;
z += 1;
z += 1;
z += 1;
z += 1;
z += 1;
z += 1;
z += 1;
z += 1;
z += 1;
}
trace("result : "+(getTimer()-ms)+" ms");
}
loop();
Last edited by RipX; 04-15-2003 at 08:19 PM.
-
Timetravelling Superhero
hmm, for loops execute pretty fast in C++ (that's what I was coding in at the moment, then checked my email and replied with that). Dang, Flash is freaking slow!
RipX: Most of my main variables are globals.
Anyway, back to playing WarCraft 3.
From here to infinity,
A J I N F I N I T Y
-
Holy ****, just realised I was using z += 1 instead of z++
This whips through at 604ms!!!! ouch
Code:
_global.MAX_VALUE = 39999;
function loop() {
var z;
var ms = getTimer();
trace("start test");
for (z=0; z<MAX_VALUE; z += 10) {
z++;
z++;
z++;
z++;
z++;
z++;
z++;
z++;
z++;
z++;
}
trace("result : "+(getTimer()-ms)+" ms");
}
loop();
Edit - does help if I put the correct variable though - doh
Code:
_global.MAX_VALUE = 39999;
function loop() {
var z;
var ms = getTimer();
trace("start test");
for (var i=0; i<MAX_VALUE; i += 10) {
z++;
z++;
z++;
z++;
z++;
z++;
z++;
z++;
z++;
z++;
}
trace("result : "+(getTimer()-ms)+" ms");
}
loop();
RipX
Last edited by RipX; 04-15-2003 at 08:39 PM.
-
w00t
Suprise suprise:
function loop() {
var MAX_VALUE = 39999;
var z;
for (i=0; i<MAX_VALUE; i++) {
z++;
}
}
timer = getTimer();
loop();
trace(getTimer()-timer)
is also faster (also you can see my state of the art timer)
-
Senior Member
I think this thread should be stickied.
Mods?
fracture2 - the sequel
fracture - retro shooter
blog - games, design and the rest
"2D is a format, not a limitation" -Luis Barriga
-
Vox
Wow!My first soon-to-be-stickied-if-all-goes-well-thread!
-
*********
i concur, nail this to the top - it's the most constructive thread in a long time
-
i have a question, whats the diff between _root and _global, besides global seems to run faster?
and is there a way to set where a fn is inside a mc, say i want it to be in root, other than using _root.loop = function() {} (since i found it slower than normal functions)
am i making sense?
-
Senior Member
I think you mean prototypes, functions that can be used anywhere in the movie from what i can gather. The syntax is:
MovieClip.prototype.myFunction = function(variables){
}
fracture2 - the sequel
fracture - retro shooter
blog - games, design and the rest
"2D is a format, not a limitation" -Luis Barriga
-
Senior Member
I think leif0's idea of moving several movie clips by putting enterFrame codes in them to do it themselves rather than putting them all into 1 container MC and moving that could have merit. I'm going through the process right now of putting the graphics into separate swfs so that the engine doesn't have the graphics built in. Because of this I have to use several container MC instead of 1 and I do see a bit of performance improvement. I'm not sure if having each MC move itself would be the best way, but having several container MC's instead of 1 does seem better.
-
first, why is it movieclip.prototye.mFn... what is the movieclip param for? i thought prototypes were fn's that could be accesed any where byt just doing mFn()
-
Senior Member
That is to declare the prototype, to access it you are right just use:
myFunction();
fracture2 - the sequel
fracture - retro shooter
blog - games, design and the rest
"2D is a format, not a limitation" -Luis Barriga
-
ok now question 2...
i heard there isnt a differnce between function thingy () {} and thingy = function() {}, but is there a differnce between thingy = function() {} and mc.prototype.thingy = function() {} ?
-
Hype over content...
A prototype differs from a function in that it is a method of a class, whereas a function is just a method.
To put it simply, if you want a function "tied" to a specific class, eg the movieclip class or the color class then from a structured point of view you should use a prototype. This of course also applies to user defined classes.
I guess it's down to how much you want to go down the OOP route. For the resource for prototypes check here: http://proto.layer51.com/default.aspx
As to actual performance, I'm afraid someone else with more OOP experience will have to post. Also if you haven't got it already, try and get hold of Colin Moock's AS for Flash MX. It's the bible.
Kirill M:
I still can't see how that would figure out? My current game has 11x7 tiles on screen at a time, which are all held in a container MC. To have an enterFrame on 77 mc's would kill it, plus I imagine you'd get glitches were the screen is being updated where not all the mc's have moved.
As to the using several container mc's and then using a movement handler (Like normal), I can't see how that would be quicker than a gotoAndStop scroller engine?
Perhaps I'm just missing the point (More than likely) or for certain engines, ie push scrollers like Zelda, it may be better(?).
Squize.
-
Squize, when you keep talking about your project, are you talkin about colorworld? or a new game???
RipX
-
sooo... prototypes (mc.prototype.fn = function(){}) are used is it is gonna be accesed alot, and can be accesed by fn() no matter where it is. and functions are like prototypes, but should be used if they are only gonna be accesed locally.
right?
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
|