Skip to content

Instantly share code, notes, and snippets.

@howmanysmall
Created September 4, 2019 22:01
Show Gist options
  • Save howmanysmall/3d8ca8e50fc90aa6df326bdf31cb1916 to your computer and use it in GitHub Desktop.
Save howmanysmall/3d8ca8e50fc90aa6df326bdf31cb1916 to your computer and use it in GitHub Desktop.
Array insertion methods.
local Functions = {}
Functions["table.insert"] = function()
local Array = {}
for Index = 1, 1E4 do
table.insert(Array, Index * 2)
end
end
Functions["#X + 1"] = function()
local Array = {}
for Index = 1, 1E4 do
Array[#Array + 1] = Index * 2
end
end
Functions["Length"] = function()
local Array = {}
local Length = 0
for Index = 1, 1E4 do
Length = Length + 1
Array[Length] = Index * 2
end
end
require(2110831719).new(1, "Array Insertion 1", Functions)
local Functions = {}
local Array = {}
for Index = 1, math.random(1E4) do Array[Index] = Index * 2 end
Functions["table.insert"] = function()
for Index = 1, 1E4 do
table.insert(Array, Index * 2)
end
end
Functions["#X + 1"] = function()
for Index = 1, 1E4 do
Array[#Array + 1] = Index * 2
end
end
Functions["Length"] = function()
local Length = #Array
for Index = 1, 1E4 do
Length = Length + 1
Array[Length] = Index * 2
end
end
require(2110831719).new(1, "Array Insertion 2", Functions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment