[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Issues with the current varargs implementation (Was: Re: inadequate documentation for select and table.unpack)
- From: Martin <eden_martin_fuhrspam@...>
- Date: Thu, 23 Jun 2016 13:59:22 -0700
On 16-06-23 02:53 AM, Viacheslav Usov wrote:
> So for n > 9, there is no reason to prefer select over {...}.
For my test case iterating table after table.pack(...) is faster
than direct select()-ing when n >= 7.
--[[
Tests relative performance between direct select() and
table.pack() and iterating table for variadic functions.
]]
local op_1 =
function(...)
local num_args = select('#', ...)
for i = 1, num_args do
local term = select(i, ...)
end
end
local op_2 =
function(...)
local args = table.pack(...)
local num_args = args.n
for i = 1, num_args do
local term = args[i]
end
end
local list_size = 10
local list = {}
for i = 1, list_size do
list[i] = i
end
local test =
function(op)
local result = 0
local start_time = os.clock()
local finish_time = start_time + 1
while (os.clock() <= finish_time) do
op(table.unpack(list))
result = result + 1
end
return result
end
print(('Number of arguments: %d'):format(list_size))
print(('Handle with select() : %10d / sec'):format(test(op_1)))
print(('Handle with table.pack: %10d / sec'):format(test(op_2)))
- References:
- inadequate documentation for select and table.unpack, Viacheslav Usov
- Re: inadequate documentation for select and table.unpack, Dirk Laurie
- Re: inadequate documentation for select and table.unpack, Roberto Ierusalimschy
- Re: inadequate documentation for select and table.unpack, Viacheslav Usov
- Issues with the current varargs implementation (Was: Re: inadequate documentation for select and table.unpack), Soni L.
- Re: Issues with the current varargs implementation (Was: Re: inadequate documentation for select and table.unpack), Patrick Donnelly
- Re: Issues with the current varargs implementation (Was: Re: inadequate documentation for select and table.unpack), Philipp Janda
- Re: Issues with the current varargs implementation (Was: Re: inadequate documentation for select and table.unpack), steve donovan
- Re: Issues with the current varargs implementation (Was: Re: inadequate documentation for select and table.unpack), Dirk Laurie
- Re: Issues with the current varargs implementation (Was: Re: inadequate documentation for select and table.unpack), KHMan
- Re: Issues with the current varargs implementation (Was: Re: inadequate documentation for select and table.unpack), Dirk Laurie
- Re: Issues with the current varargs implementation (Was: Re: inadequate documentation for select and table.unpack), KHMan
- Re: Issues with the current varargs implementation (Was: Re: inadequate documentation for select and table.unpack), Viacheslav Usov
- Re: Issues with the current varargs implementation (Was: Re: inadequate documentation for select and table.unpack), Dirk Laurie
- Re: Issues with the current varargs implementation (Was: Re: inadequate documentation for select and table.unpack), Viacheslav Usov