Thread: Cinema Workshop
View Single Post
Old 07-04-2011, 02:35 PM   #10
Join Date: May 2011
Posts: 85

Submissions (2)

BBQ will become famous soon enough (30)BBQ will become famous soon enough (30)


Originally Posted by Captain Griffen
Why would you be very sure of that? Consider that we aren't just dealing with a VM, we're dealing with a Blizzard VM.
Okay, here's a post by grim001 that I stumbled upon:
"I once had the idea that it would be better to use only global vars in my engine in order to avoid repeatedly initializing locals. The result is that the whole engine ran about 20% slower.

According to Pipedream the speed of variable access depends on how many other vars there are in that scope. vJASS maps can create thousands of global vars for structs, so globals have a very long list to sort through, whereas locals typically only have a few.

So basically, whichever you have fewer of (locals or globals) should be faster, but you will always have more globals than locals unless you are a freak."
Perhaps you trust him more than you trust me.

Originally Posted by Anitarf
We'd need to test this in a map where you can easily switch between having no and a few hundred declared variables/arrays (by the use of nested textmacros) and then do a hundred get/set operations (again with textmacros, no loops) and test how long that takes depending on the number of global variables in the map and depending on whether the get/set operations are being done on a global or a local, so four test cases in total. Someone with a working japi would need to do this since I don't trust fps tests with something as fast as variable operations, but this is really a subject for a new thread.
Unfortunately, textmacros cannot be nested.

Originally Posted by Anitarf
It was my understanding that arrays were allocated incrementally as needed, but maybe I misunderstood what this post says. In either case, if local variables are indeed faster than globals when there are many globals in the map then this is a moot point as the amount of operations I do on the local array should out-weight the cost of its allocation.
While the thread you linked to is very awesome (thanks!), it doesn't seem to show whether the memory is allocated incrementally or not.

But anyway, here's a post by weaaddar:
"An array in jass will always use 8192 elements. No matter if your only using 1 or 400. Its very bad to use arrays that you do not need to use. As each type in war3 uses a 4kb integer as its pointer. So you are using roughly 32kb of ram per array. Sure it doesn't seem like much but remember that types also have there own memory usage on the handling stack."
BBQ is offline   Reply With Quote