lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


After caching everything in locals and using tostring(rnd()) instead
of table.concat() since it adds a constant overhead, it turns out that
the string.format method takes around 1.2 times as long as the concat
operator in both Lua 5.1 and LuaJIT2(beta2, I dont have a more recent
version laying around and my *nix laptop doesn't have a webb
connection here).

-- Pierre-Yves



2011/4/13 Pierre-Yves Gérardy <pygy79@gmail.com>:
> On Wed, Apr 13, 2011 at 16:25, Henning Diedrich <hd2010@eonblast.com> wrote:
>>     ----------------------------------------------------------------------------o-
>>     x=[1..100] elements in t[i] = 'abc' .. i
>>     +: '[' .. table.concat(t) .. ']'
>>     x: string.format('[%s]', table.concat(t))
>>     ----------------------------------------------------------------------------o-
>
> The first example has only one global+table lookup for two in the
> second. Or perhaps you cached them in locals but did not display it?
>
> -- Pierre-Yves
>