lua-users home
lua-l archive

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


> This is a quick test with Lua4 vs. Lua5 (the script is at the very bottom).
> [...]

I did exactly the same tests on my machine (gcc 2.96/Linux 2.4):

Lua4 (local f) - the function f was declared as local
0.33
0.43
Lua5.0b (local f)
0.33
0.44
Lua4 (global f) - the function f was NOT declared as local
0.38
0.43
Lua5.0b (global f)
0.41
0.49

The largest difference was 14%. The difference in the case that used
tag methods with f local was 2%. (BTW, don't ask me why there is any
difference between f local or global when using metatables; the second
loop does not use the variable "f" at all! This only shows how tests can
be sensitive to details.)

Then, I changed the test a little, so that "f" makes a minimum of work:

  f = function ()
    return 2+3
  end

Now the second case (global f) results in

lua4.0
0.46
0.66
lua5.0b
0.44
0.56

(Again, don't ask me why the slowdown is not the same with and without
tag methods/metatables...)


> Aside from the fact that Lua4 is simply faster on function calls by up to 30%

This is one point I do not argue (although, as the tests sugest, this
difference is quite smaller when the function does anything). But this
slowdown is a consequence of coroutines, not of metatables. If someone
argues that we shold remove coroutines from the language so it would run
faster, then we have a very different scenario.

-- Roberto