lua-users home
lua-l archive

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


> Well, I tried a simple test, but lua complained -- I think the arguments
> to collectgarbage need to be ints rather than strings!

are you sure you're using 5.1-work - it seems like you may
be using 5.0 instead ?

tmp> /usr/local/src/lua/lua-5.0.2/bin/lua myers 
/usr/local/src/lua/lua-5.0.2/bin/lua: myers:8: bad argument #1 to `collectgarbage' (number expected, got string)
stack traceback:
        [C]: in function `collectgarbage'
        myers:8: in main chunk
        [C]: ?
tmp> 
tmp> /usr/local/src/lua/lua-5.1-work0/bin/lua myers 
at n =  1000            count garbage:  28
at n =  2000            count garbage:  27
at n =  3000            count garbage:  29
at n =  4000            count garbage:  34

you could use print(_VERSION) to confirm the version:

tmp> lua -e 'print(_VERSION)'
Lua 5.1 (work)
tmp> 

> Anyway, I found it started quite spritely but, now at n = 296000 it's very
> slow (99.1% cpu according to top).

i think that is expected because the loops are moving a lot of data
and creating lots of garbage as n gets bigger.

section 11.6 of Roberto's book explains why in more detail.
it has also been discussed on this mailing list in the past:

	http://lua-users.org/lists/lua-l/2003-05/msg00107.html