- Joined
- Jul 10, 2007
- Messages
- 6,306
gone
Last edited:
debug private static boolean enabled = true
Nes, why do you have a static == 8191 check, when it is allowed to have more than 8191 instances of the same struct by setting the instances with struct[INSTANCES]?
Another thing is, as far as I have seen this does NOT provide any more features than the default allocation and deallocation.
debug set this = 1/0
debug set enabled = false
Sevion didn't write his module perfectly, so it was only a matter of time before somebody else would submit a better version >.>.
private static method onInit takes nothing returns nothing
local integer i = 0
set recycler[8191] = 0 //so that the array doesn't reallocate over and over again
loop
set recycler[i] = i + 1
exitwhen i == 8190
set i = i + 1
endloop
endmethod
struct standard
endstruct
struct alloc extends array
implement Alloc
endstruct
private function Actions takes nothing returns nothing
local integer sw
local integer i
local real array ticks
local string output = ""
local boolean b = true
local integer f=0
local integer g=0
local integer instance
set i = 0
call TriggerSleepAction(0)
set sw = StopWatchCreate()
loop
exitwhen i == ITERATIONS
set instance = alloc.allocate()
set i = i + 1
endloop
set ticks[1] = StopWatchTicks(sw)
call StopWatchDestroy(sw)
//set output = output + I2S(ITERATIONS) + " iterations of Test #2 took " + I2S(StopWatchMark(sw)) + " milliseconds to finish.\n\n"
set i = 0
call TriggerSleepAction(0)
set sw = StopWatchCreate()
loop
exitwhen i == ITERATIONS
set instance = standard.create()
set i =i + 1
endloop
set ticks[0] = StopWatchTicks(sw)
call StopWatchDestroy(sw)
//set output = I2S(ITERATIONS) + " iterations of Test #1 took " + I2S(StopWatchMark(sw)) + " milliseconds to finish.\n"
if (ticks[0] > ticks[1]) then
set ticks[2] = 100 - (ticks[1]/ticks[0] * 100)
set output = output + "Test #2 was " + R2S(ticks[2]) + "% faster than Test #1\n\n"
else
set ticks[2] = 100 - (ticks[0]/ticks[1] * 100)
set output = output + "Test #1 is " + R2S(ticks[2]) + "% faster than Test #2\n\n"
endif
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, output)
endfunction
However for some reason (even with trying many variations) the first time calling the custom allocation it's ~15-20% faster. No, I didn't test in debug mode.
set count = checkRegion(start, end)
set count = count + checkRegion(start, end)