Scripting Moderators ds1-e Posted July 8, 2019 Scripting Moderators Share Posted July 8, 2019 (edited) Hey, i would like to know which is faster, and better to use. Or there's no any difference in performance between them? For example in render, or any different usage. As far i understand from reading IIYAMA's posts, for render it's better to use array structure? Edited July 8, 2019 by majqq Link to comment
Administrators Lpsd Posted July 8, 2019 Administrators Share Posted July 8, 2019 Can you explain in more detail what you mean by object vs array? Are you referring to JSON data format? If you're referring to element (object) data storage, versus standard storage in Lua tables, then Lua tables are always going to perform better. However, some more understanding of what you mean / what you're trying to do would help explain it Link to comment
Scripting Moderators ds1-e Posted July 8, 2019 Author Scripting Moderators Share Posted July 8, 2019 1 minute ago, LopSided said: Can you explain in more detail what you mean by object vs array? Are you referring to JSON data format? If you're referring to element (object) data storage, versus standard storage in Lua tables, then Lua tables are always going to perform better. However, some more understanding of what you mean / what you're trying to do would help explain it Lua tables, check first post, i've edited it. Link to comment
Moderators IIYAMA Posted July 9, 2019 Moderators Share Posted July 9, 2019 (edited) On 08/07/2019 at 14:15, LopSided said: Can you explain in more detail what you mean by object vs array? Are you referring to JSON data format? JS object format types, which is more or less the same as JSON. Just it is not a string but an entity. Which is a way for myself to separate array structured tables from tables with mixed keys. Might be good or bad practice, I myself to be honest do not know. @majqq If you need confirmation, then the best way is to test it yourself. local newTable_array = {} local newTable_object = {} local loops = 1000 for i = 1, 1000 do newTable_array[i] = true newTable_object[i .. ""] = true end do local timeNow = getTickCount () for _ = 1, loops do for i=1, #newTable_array do local value = newTable_array[i] end end outputChatBox(getTickCount () - timeNow) end do local timeNow = getTickCount () for _ = 1, loops do for key, value in pairs(newTable_array) do end end outputChatBox(getTickCount () - timeNow) end do local timeNow = getTickCount () for _ = 1, loops do for key, value in ipairs(newTable_array) do end end outputChatBox(getTickCount () - timeNow) end do local timeNow = getTickCount () for _ = 1, loops do for key, value in pairs(newTable_object) do end end outputChatBox(getTickCount () - timeNow) end Edited July 9, 2019 by IIYAMA 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now