lua-users home
lua-l archive

Re: Calculating estimate for size of a lua table

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


Thanks for the correction.

I did some benchmarking using the following code:

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")

which consistently printed a size of about 39 bytes for each hash entry on both PUC Lua 5.4 and LuaJIT

For the list part I simply used "t[i] = i" in the above code. Surprisingly the list part only takes 13 bytes per entry on LuaJIT (!) vs 26 bytes per entry on Lua 5.1 and Lua 5.4.

On 13.08.22 19:32, Xmilia Hermit wrote:
[Lars Müller:

Re: Calculating estimate for size of a lua table, Xmilia Hermit
  • Re: Calculating estimate for size of a lua table, Xmilia Hermit
  • AltStyle によって変換されたページ (->オリジナル) /