lua-users home
lua-l archive

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


Am 23.06.2016 um 13:29 schröbte Dirk Laurie:

The most interesting result, though, occurred in Lua 5.1.
'select' for very short varargs is indeed very fast.

$ lua5.1 vabench.lua
Lua 5.1, N: 1000000
select #: 0  time: -0.128542 secs
{...}  #: 0  time: 0.003643 secs
select #: 1  time: -0.087071 secs
{...}  #: 1  time: 0.094904 secs
select #: 2  time: -0.036425 secs

The reason is `LUA_COMPAT_VARARG` which generates additional garbage and throws off my attempt at calculating and subtracting the loop overhead. Here are the correct (relative) timings for Lua 5.1 (without `LUA_COMPAT_VARARG`):

Lua 5.1, N: 1000000
select #: 0  time: 0.120215 secs
{...}  #: 0  time: 0.162073 secs
select #: 1  time: 0.128983 secs
{...}  #: 1  time: 0.220188 secs
select #: 2  time: 0.192243 secs
{...}  #: 2  time: 0.243017 secs
select #: 3  time: 0.240334 secs
{...}  #: 3  time: 0.266548 secs
select #: 4  time: 0.284831 secs
{...}  #: 4  time: 0.292167 secs
select #: 5  time: 0.342468 secs
{...}  #: 5  time: 0.313766 secs
select #: 6  time: 0.402705 secs
{...}  #: 6  time: 0.338228 secs
select #: 7  time: 0.473817 secs
{...}  #: 7  time: 0.36173 secs
select #: 8  time: 0.556459 secs
{...}  #: 8  time: 0.450496 secs
select #: 16  time: 1.106638 secs
{...}  #: 16  time: 0.594495 secs
select #: 32  time: 2.780478 secs
{...}  #: 32  time: 0.982129 secs
select #: 64  time: 7.671746 secs
{...}  #: 64  time: 1.80036 secs


Philipp