|
Right now I'm just using "function() end", but I'm wondering if there's a faster built-in one that does the same thing. |
|
|
Almost all of the ones that already exist
local start = tick()
for x = 1, 1000, 1 do
(math.random)()
end
print(tick() - start)
local start = tick()
for x = 1, 1000, 1 do
(function() end)()
end
print(tick() - start) |
|
|
Or you can just predefine the function as a local variable for the fastest speed (Fasted I know how to get at least)
Also if I'm misunderstanding the question I'm sorry
local start = tick()
for x = 1, 1000, 1 do
(math.random)()
end
print(tick() - start)
local f = function() end
local start = tick()
for x = 1, 1000, 1 do
(f)()
end
print(tick() - start) |
|
|
Any one that accepts any type of argument? |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
local x;
there. |
|
|
Alright, I found tick, time, versio, and UserSettings. Looks like tick or time are the fastest. |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
you don't need a function, i don't see why it matters |
|
|
It needs to be callable with any argument without showing noticeable effects. I basically need an empty function, and I was just wondering if there were any faster C-sided ones that would achieve the same effect as calling "function() end". |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
Pretty sure something like
local function nop()
end
will be faster than 'tick' |
|
eLunateJoin Date: 2014-07-29 Post Count: 13268 |
Quick pull out the null machine pew pew pew |
|
|
Actually, I just tested it. tick is faster. |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
Meh, probably |
|
eLunateJoin Date: 2014-07-29 Post Count: 13268 |
Quick quick pull out the void machine weee wooo weee wooo |
|
|
Cntkillme is right, local function nop() end would be faster
local function test()
end
local t = tick
local start = t()
for x = 1, 1000, 1 do
tick()
end
local withTick = (t() - start)
start = t()
for x = 1, 1000, 1 do
test()
end
local withLocal = (t() - start)
print(withTick > withLocal) |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
You're getting a global, it's not only a C call.
local t = tick
local start = t()
for x = 1, 1000, 1 do
t()
end
local withTick = (t() - start) |
|
|
I called it globally on purpose (And didn't for time measuring) |
|
|
Also even if I do it like that, tick() is slower |
|
|
I called it locally in my test. |
|
|
I tried calling it locally it made no difference. |
|
|
I did 1000000 iterations. |
|
|
I just did it with 1,000,000 too, still no difference, tick is still slower. |
|
|
What if you passed it a few arguments? |
|
|
I passed 7,999 arguments to each one
No difference
tick
is
slower |
|
|
Well, for whatever reason, tick is faster on my end. |
|
|