• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[vJASS] extended vs normal structs

Status
Not open for further replies.
Level 17
Joined
Apr 27, 2008
Messages
2,455
If you're a speedfreak and/or a script size freak, go for struct extends array.

Really, the only time you would use a struct extends array, is when you don't need the default struct allocators (ofc also if you just want to use the struct api without any allocator)
 
You have to stress test. But the speed difference behind that is mostly based on logic, because obviously a method that uses fewer calls/checks will perform faster.

However, it is not super necessary unless you are a speed freak. There are other uses for extending array, but usually you'll see it just used for more efficient allocation/deallocation.

If you are still learning vjass, in my opinion you don't have to really worry about it. You can just use normal structs.
 
@ PurgeandFire111
I know that a fewer function call is faster but how do I make an fps speed test ?

You'll have to stress test it. You'll have an empty map where you run one code, and you have to loop it like tens of thousands of times. Then record the fps (type /fps in chat) and run the code and see how much it has dropped. Then close the map, change the code to run your other code, and then do the same process.

However, the results aren't conclusive unless the difference is significant. (like 10 or so fps) But even then, the only applies to extreme cases. Poot summed it up, you don't really have to worry about it. You won't notice the speed difference. Most system makers will only go out of their way for minor speed gains just to prevent critique on that end.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Just type "/fps" in game.

But anyway you have to know lot of things to make a good stress test, and it will tell you only which way is the faster, you can't really count on accuracy.
Note that the fps drop is not supposed to be linear, so for the two test codes you would have to get the same fps frop and compare how many operation you do in code A, and code B.
Plus in real codes, the struct allocation is clearly not the most expensive thing, while the api is uglier and error prone when you inline and use a custom struct allocator and struct extends array.
Hence the reason why struct extends array are useless in most of cases (at least when you need usual struct allocators)
 
Status
Not open for further replies.
Top