forked from OverlordAkise/gmod-lua-performance
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable_empty_vs_new.lua
More file actions
62 lines (48 loc) · 1.95 KB
/
Copy pathtable_empty_vs_new.lua
File metadata and controls
62 lines (48 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
--Warning: Runtime > 15 seconds!!
local smallnumtable = {}
local bignumtable = {}
local smallstrtable = {}
local bigstrtable = {}
LuctusCompareOften(1,0.1,1000,{
{"--",function() for i=1,10000 do table.insert(bignumtable,i) end end},
{"--",function() for i=1,10 do table.insert(smallnumtable,i) end end},
{"--",function() for i=1,10000 do bigstrtable[ranStr(14)] = i end end},
{"--",function() for i=1,10 do smallstrtable[ranStr(14)] = i end end},
{"table.Empty numerical on small",function() table.Empty(smallnumtable) end},
{"table.Empty numerical on big ",function() table.Empty(bignumtable) end},
{"table.Empty stringind on small",function() table.Empty(smallstrtable) end},
{"table.Empty stringind on big ",function() table.Empty(bigstrtable) end},
{"--",function() for i=1,10000 do table.insert(bignumtable,i) end end},
{"--",function() for i=1,10 do table.insert(smallnumtable,i) end end},
{"--",function() for i=1,10000 do bigstrtable[ranStr(14)] = i end end},
{"--",function() for i=1,10 do smallstrtable[ranStr(14)] = i end end},
{"table = {} numerical on small",function() smallnumtable = {} end},
{"table = {} numerical on big ",function() bignumtable = {} end},
{"table = {} stringind on small",function() smallstrtable = {} end},
{"table = {} stringind on big ",function() bigstrtable = {} end},
})
-- Older code:
--[[
--# Tabsize 100000
--table.Empty 0.00047110000002704
--tab = {} 0.000022799999953804 2.2799999953804e-05
--# Tabsize 10
--table.Empty 0.0000014999999962129 1.4999999962129e-06
--tab = {} 0.00000019999998812636 1.9999998812636e-07
local tabsize = 100000
local tab1 = {}
local tab2 = {}
for i=1,tabsize do
table.insert(tab1,math.random())
table.insert(tab2,math.random())
end
print("Tabsize",tabsize)
ss = SysTime()
table.Empty(tab1)
es = SysTime()
print("table.Empty",(es-ss))
ss = SysTime()
tab2 = {}
es = SysTime()
print("tab = {}",(es-ss))
--]]