Discuss and collaborate on GML scripts

You are not logged in.

#1 2007-11-07 16:17:41

Registered: 2007-10-17
Posts: 110


Well I don't really feel like to explain very much about perftest here, - almost nobody seems ever interested, but it's simply a testing utility which I "made" which can help testing your scripts if you want to know which of the two (or methods) is the fastest! And I think it can have it's uses here:

gmc topic
above shows that the speed of the repeat loop is much faster than the speed of any other loop!

64digits download link
yoyogames' link (pressing f3 will open the folder where the game is located)

The zip package contains quite a few files, pressing F1 will explain most uses for them, but I'll explain a bit more about the gmk structure I used here:

There are only a few important scripts:
InitTests Is propably most important if you want to add your own script(s):

Expandif (!onlyextra)

the part in that if statement contains the scripts which will be "executed" at start: those scripts contain all functions which need to be executed. If you want to have your own scripts be tested put a "link" to the TEST-startup script (not the actual script, but the script which has the code like shown below) there and make sure the rest gets commented.

Every script in this will consist of quite a few "array variables", the manual explains the use of all these quite well I think. To test your custom script you could use:

ExpandTests[i,TEST_CLASS] = 	"OWN TEST";
Tests[i,TEST_PRETESTS] = 	"//any initialization such as d3d_start or list creation";
Tests[i,TEST_PRESCRIPT] = 	"//any initialization of variables/global variables/instances you use";
Tests[i,TEST_FUNC] = 	"script_test(arg0,arg1,...)";
Tests[i,TEST_POSTSCRIPT] = 	"//this code is executed every time just after the tests";
Tests[i,TEST_POSTTESTS] = 	"this code is only executed once after all tests (things like d3d_end() here)";
Tests[i,TEST_NAME] = 	Tests[i,TEST_FUNC];
i += 1;	//<- don't forget this! Never! - If you forget it the whole program will be messed up...

Of course the extra "external edit file" still works, however I didn't upgrade it, and according to most people it was a bit hard to use. So unless somebody explains to me some very good reason to update it, I won't update it anymore :S.

I know smarty is going to kill me now (if he noticed it wink) since all code (pretest,prescript,func,postscript,posttest) are executed with execute_string.. However the latency test already takes into account (most of) the speed problems with this.

Last edited by paul23 (2007-11-07 16:18:51)


#2 2007-11-07 18:11:53

Registered: 2007-10-09
Posts: 48

Re: Perftest

The problem I see with the test (at least the plot of the results) is that the loops do nothing.  You would never have a loop doing nothing in a game and it doesn't really give you a good idea of how the loop would perform when actually doing something useful.  I mean, this makes it look like a simple repeat statement is many times faster than any other kind of loop.  That's true until you make it do something at which point the difference from any other loop might be negligible.


#3 2007-11-07 19:29:29

Registered: 2007-10-17
Posts: 110

Re: Perftest

yeah that's true, but it also shows the "repeat+counter" -> and then you'll still see the repeat is the fastest loop, and whenever you want to look for the smallest bits the repeat loop WILL be faster (+it's not THAT more difficult to use it it?). But as seen in the difference between the "simple repeat" (just empty nothing inside it) and a repeat with count (with i+=1 inside it) the speed of the loop is indeed pretty much negligible. But maybe even more important are the differences between normal and "var declared" loops.. In the repeat statement you'll know that at least the "loop speed" is the same, the only difference is how the variable is declared, and the counting INSIDE the loop. This means that the only difference is in the adding. (i+=1;)

But the loops aren't the only thing I tested, in fact I tested about all functions currently available in gamemaker (only particles I left out - they're hard to make "general" tests with). And you can easily add your own scripts for testing tongue.
Another "funny" thing I've noticed for example is that drawing sprites on the screen is "normal" - outside is "fast" - but partly is outside is actually "slow"! same for text etc. Helpfull? - well not really, I can't think of any method to prevent/workaround this (nor is the speed difference that big), still it's funny.
Or that the mp_grid_path functions DON'T take test fast if the ending spot is free or not (yet it seem to have the same speed as in an empty grid, so once it "encounters" the full ending spot it actually stops instead of going through the full map - or at least that's what I think).


Board footer

Powered by FluxBB