I made a simple .dll file that has only one exported function which returns the text string "1".
Then I executed the following:
var
d = world.timeofday
for (var/i = 1 to 100000) call("mydll", "function")("5 + 5")
world.log << "Test took [world.timeofday - d] ticks."
The above test case takes 2 ticks, even though the DLL doesn't do any actual processing.
When the number goes even higher I end up having to wait 30 seconds. This seems odd since all this is supposed to be doing is calling a function that returns a static value.
I don't know if I'm doing anything wrong, so if I am please point that out. But AFAIK this is a bug with the way BYOND talks to the DLL.
Expected Results:
I expected the calls to finish within 0 ticks even if the loops were in the millions or billions.
Actual Results:
Something is causing a delay of 2 ticks in the above case. Since I'm only returning a static value I'm assuming that this is something BYOND does that I can't see.
Does the problem occur:
Every time? Or how often?
Every time.
In other games?
I have a reproducible test case.
In other user accounts?
Untested.
On other computers?
Untested.
When does the problem NOT occur?
The problem does not occur if the amount of loops is low enough. However, for my test case I was using a higher value as I want to compare BYOND's native functionality against the one I can provide through the use of a DLL file. This delay is skewing the results.
Workarounds:
None.
One thing I can say for sure is 2 ticks for 100K loops really isn't horrible. The loop is doing quite a bit of processing all on its own: It's pushing those strings onto the stack, making the DLL call (for all I know there could be an efficiency issue in this part we can improve on), and dealing with the return value. 2 μs per call probably isn't bad, all things considered.