- Joined
- Sep 26, 2009
- Messages
- 9,534
Linked list is going to be way faster of course. I just don't know how much faster.
Either way you're going to need a linked list too.
Either way you're going to need a linked list too.
globals
unit u
trigger t = CreateTrigger()
endglobals
function i takes nothing returns nothing
local integer s = 500
loop
set u = CreateUnit(Player(15), 'ushd', -1000, -1000, 0)
exitwhen 0 == s
set s = s - 1
endloop
call TriggerRegisterUnitInRange(t, u, 1000, null)
call TriggerRegisterUnitInRange(t, u, 1000, null)
call TriggerRegisterUnitInRange(t, u, 1000, null)
call TriggerRegisterUnitInRange(t, u, 1000, null)
call TriggerRegisterUnitInRange(t, u, 1000, null)
call TriggerRegisterUnitInRange(t, u, 1000, null)
call TriggerRegisterUnitInRange(t, u, 1000, null)
call TriggerRegisterUnitInRange(t, u, 1000, null)
call TriggerRegisterUnitInRange(t, u, 1000, null)
call TriggerRegisterUnitInRange(t, u, 1000, null)
call TriggerRegisterUnitInRange(t, u, 1000, null)
call TriggerRegisterUnitInRange(t, u, 1000, null)
endfunction
struct tester extends array
private static method onInit takes nothing returns nothing
call i()
endmethod
endstruct
globals
group g = CreateGroup()
unit u
trigger t = CreateTrigger()
endglobals
function d takes nothing returns boolean
call GroupEnumUnitsInRange(g, -1000, -1000, 1000, null)
loop
set u = FirstOfGroup(g)
exitwhen null == u
call GroupRemoveUnit(g, u)
endloop
return false
endfunction
function r takes nothing returns nothing
call TriggerEvaluate(t)
endfunction
function i takes nothing returns nothing
local integer s = 500
local boolexpr b = Condition(function d)
loop
call CreateUnit(Player(15), 'ushd', -1000, -1000, 0)
exitwhen 0 == s
set s = s - 1
endloop
call TriggerAddCondition(t, Or(b,b))
call TimerStart(CreateTimer(), .01, true, function r)
endfunction
struct tester extends array
private static method onInit takes nothing returns nothing
call i()
endmethod
endstruct
globals
unit u
endglobals
function i takes nothing returns nothing
local integer s = 500
local integer ev = 40
loop
set u = CreateUnit(Player(15), 'ushd', -1000, -1000, 0)
if (0 < ev) then
set ev = ev - 1
call TriggerRegisterUnitInRange(CreateTrigger(), u, 1000, null)
endif
exitwhen 0 == s
set s = s - 1
endloop
endfunction
struct tester extends array
private static method onInit takes nothing returns nothing
call i()
endmethod
endstruct
globals
group g = CreateGroup()
unit u
trigger t = CreateTrigger()
endglobals
function d takes nothing returns boolean
call GroupEnumUnitsInRange(g, -1000, -1000, 1000, null)
loop
set u = FirstOfGroup(g)
exitwhen null == u
call GroupRemoveUnit(g, u)
endloop
return false
endfunction
function r takes nothing returns nothing
call TriggerEvaluate(t)
endfunction
function i takes nothing returns nothing
local integer s = 500
local boolexpr b = Condition(function d)
loop
call CreateUnit(Player(15), 'ushd', -1000, -1000, 0)
exitwhen 0 == s
set s = s - 1
endloop
set b = Or(b,b) //2
set b = Or(b,b) //4
set b = Or(b,b) //8
set b = Or(b,b) //16
set b = Or(b,b) //32
set b = Or(b,b) //64
call TriggerAddCondition(t, b)
call TimerStart(CreateTimer(), .1, true, function r)
endfunction
struct tester extends array
private static method onInit takes nothing returns nothing
call i()
endmethod
endstruct
globals
unit u
endglobals
function i takes nothing returns nothing
local integer s = 500
local integer ev = 64
loop
set u = CreateUnit(Player(15), 'ushd', -1000, -1000, 0)
if (0 < ev) then
set ev = ev - 1
call TriggerRegisterUnitInRange(CreateTrigger(), u, 1000, null)
endif
exitwhen 0 == s
set s = s - 1
endloop
endfunction
struct tester extends array
private static method onInit takes nothing returns nothing
call i()
endmethod
endstruct
globals
integer array XXXX
endglobals
struct Tester extends array
private static integer array myArray
private static method proxy takes nothing returns nothing
//! textmacro SpreadBench takes A
/*
set XXXX[$A$] = $A$
set XXXX[$A$] = $A$
set XXXX[$A$] = $A$
set XXXX[$A$] = $A$
set XXXX[$A$] = $A$
set XXXX[$A$] = $A$
set XXXX[$A$] = $A$
set XXXX[$A$] = $A$
set XXXX[$A$] = $A$
set XXXX[$A$] = $A$
*/
set .myArray[$A$] = $A$
set .myArray[$A$] = $A$
set .myArray[$A$] = $A$
set .myArray[$A$] = $A$
set .myArray[$A$] = $A$
set .myArray[$A$] = $A$
set .myArray[$A$] = $A$
set .myArray[$A$] = $A$
set .myArray[$A$] = $A$
set .myArray[$A$] = $A$
/*
local integer a$A$ = $A$
local integer b$A$ = $A$
local integer c$A$ = $A$
local integer d$A$ = $A$
local integer e$A$ = $A$
local integer f$A$ = $A$
local integer g$A$ = $A$
local integer h$A$ = $A$
local integer i$A$ = $A$
local integer j$A$ = $A$
*/
//! endtextmacro
//! runtextmacro SpreadBench("0")
//! runtextmacro SpreadBench("1")
//! runtextmacro SpreadBench("2")
//! runtextmacro SpreadBench("3")
//! runtextmacro SpreadBench("4")
//! runtextmacro SpreadBench("5")
//! runtextmacro SpreadBench("6")
//! runtextmacro SpreadBench("7")
//! runtextmacro SpreadBench("8")
//! runtextmacro SpreadBench("9")
endmethod
//! textmacro Bench
call .proxy()
call .proxy()
call .proxy()
call .proxy()
call .proxy()
call .proxy()
call .proxy()
call .proxy()
call .proxy()
call .proxy()
//! endtextmacro
private static method repeat takes nothing returns nothing
local integer i = 2 //Configurable.
loop
//! runtextmacro Bench()
//! runtextmacro Bench()
//! runtextmacro Bench()
//! runtextmacro Bench()
//! runtextmacro Bench()
//! runtextmacro Bench()
//! runtextmacro Bench()
//! runtextmacro Bench()
//! runtextmacro Bench()
//! runtextmacro Bench()
set i = i - 1
exitwhen i == 0
endloop
endmethod
private static method onInit takes nothing returns nothing
call TimerStart(CreateTimer(), 0.05, true, function thistype.repeat)
endmethod
endstruct
The only time this stuff is going to matter is in code that is called massively, like projectile systems or timer systems.
The biggest overhead I had in the timer system I wrote was actually global arrays. There were specifically 6 lines of global array reads/writes that caused the performance hit.
Also keep in mind that most of the overhead from calling functions is the arguments. Compare a function call with 6 arguments to a function call with none and you will see a major speed difference. When Starcraft 2 beta first came out, one person benched JASS stuff and Galaxy stuff and this is where I saw the stats for a function call with 6 arguments =).
Code readability, maintainability, and modularity is more important in most cases, but if you have a timer running 32x a second or some piece of code that is executing at obscene rates, you'll want to squeeze out every last ounce of performance you can =).