Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local unit, weapon
- function doSomething()
- _G['lol'] = 1
- end
- ArmedUnits = {}
- Units = {}
- Weapons = {}
- for i=1, 90000,1 do
- ArmedUnits[i] = { unit = 5, weapon = 5 }
- Units[i] = 5
- Weapons[i] = 5
- end
- t1 = os.clock()
- for i=1, 90000,1 do
- if Units[i] == Weapons[i] then doSomething() end
- end
- t2 = os.clock()
- for i=1, 90000,1 do
- unit = ArmedUnits[i].unit
- weapon=ArmedUnits[i].weapon
- if unit == weapon then doSomething() end
- end
- t3 = os.clock()
- print( "Method 1: " .. t2-t1 )
- print( "Method 2: " .. t3-t2 )
- -- Output:
- C:\Misc\binlua>lua52 test.lua
- Method 1: 0.016
- Method 2: 0.019
- C:\Misc\binlua>lua52 test.lua
- Method 1: 0.016
- Method 2: 0.019
- C:\Misc\binlua>lua52 test.lua
- Method 1: 0.015
- Method 2: 0.02
- C:\Misc\binlua>lua52 test.lua
- Method 1: 0.016
- Method 2: 0.019
- C:\Misc\binlua>lua52 test.lua
- Method 1: 0.016
- Method 2: 0.02
- C:\Misc\binlua>lua52 test.lua
- Method 1: 0.015
- Method 2: 0.02
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement