lua-users home
lua-l archive

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


On Mon, Nov 23, 2020 at 9:59 PM Petri Häkkinen wrote:
Are pure dictionaries also affected?


Yes.


$ cat pure_dict.lua
local game_field = {}
local game_size = 2^20  -- 2^20 is fast, but (2^20-1) is VERY slow
local size_delta = tonumber(arg[1])
game_size = game_size + size_delta
print("size = 2^20 + "..size_delta)

local function initialize_game_field()
   for j = 1, game_size do
      game_field["cell#"..j] = "white"
   end
   for j = 1 + game_size, 2*game_size do
      game_field["cell#"..j] = nil
   end
   for j = 1 + 2*game_size, 3*game_size do
      game_field["cell#"..j] = "black"
   end
end

initialize_game_field()

$ time lua pure_dict.lua 0
size = 2^20 + 0

real    0m11.143s
user    0m9.416s
sys     0m0.296s

$ time lua pure_dict.lua -1
size = 2^20 + -1

(Could not wait so long to get the result time)