AllCrimes
Member
I put together another performance test for my own sanity. DISCLAIMER: There's no perfect way to test structs (that I can think of) without using the variable_struct_get and variable_struct_set from within the for loop and the performance hit of these as opposed to dot notation is unknown. This of course also requires calling a string() parse on the iteration (i). The best thing I could think of to account for this was to loop through __numLoops calling string(i), getting the time it took to complete, and removing that from the final time calculation on the struct test. If anyone can think of a better way to test this please let me know. This particular test was run with the YYC, and 100,000 iterations.
Some observations...
Array with an enum:
+ By far the fastest speed
+ Intellisense in the IDE from the enum itself
- You must continue to fake inheritance
Struct:
+ Proper inheritance
- No intellisense (Cannot be faked)
- Very slow (Cannot be faked)
Personally, without further evidence, the convenience of structs themselves is not worth the performance cost if you intend to have them represent a large number of entities but their usefulness might be seen as wrappers for sets of functions & things of that nature. Also bare in mind that you lose intellisense, which means you have to remember the properties down through all your inheritances. Please, please correct me if you see otherwise.
You can find the code here:
EDIT: Important further reading:
Some observations...
Array with an enum:
+ By far the fastest speed
+ Intellisense in the IDE from the enum itself
- You must continue to fake inheritance
Struct:
+ Proper inheritance
- No intellisense (Cannot be faked)
- Very slow (Cannot be faked)
Personally, without further evidence, the convenience of structs themselves is not worth the performance cost if you intend to have them represent a large number of entities but their usefulness might be seen as wrappers for sets of functions & things of that nature. Also bare in mind that you lose intellisense, which means you have to remember the properties down through all your inheritances. Please, please correct me if you see otherwise.
You can find the code here:
GML Perf Test - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
pastebin.com
EDIT: Important further reading:
Performance testing (Including structs)
I put together another performance test for my own sanity. DISCLAIMER: There's no perfect way to test structs (that I can think of) without using the variable_struct_get and variable_struct_set from within the for loop and the performance hit of these as opposed to dot notation is unknown. This...
forum.yoyogames.com
Last edited: