lua-users home
lua-l archive

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


Lars Müller:

for i = 1, 10 do collectgarbage"collect" end; c = collectgarbage"count"; t = {}; for i = 1, 1e7 do t[i+.5] = i end; d = collectgarbage"count"; print((d - c) * 1e3 / 1e7, "bytes per entry")

I just noticed the multiplyer for "count" is wrong. It should be 2^10. So the following code should be better:

for i = 1, 10 do collectgarbage"collect" end; c = collectgarbage"count"; t = {}; for i = 1, 0x1000000 do t[i+.5] = i end; d = collectgarbage"count"; print((d - c)*2^10/0x1000000, "bytes per entry")

Which gets me right on 32 bytes and other builds of PUC Lua 24. This depends on the compiler which might want to use 16 byte alignment for the node or only 8.

Regards,
Xmilia