This repository was archived by the owner on May 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbench.lua
More file actions
executable file
·89 lines (71 loc) · 1.28 KB
/
bench.lua
File metadata and controls
executable file
·89 lines (71 loc) · 1.28 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
if jit then
jit.off()
end
local test = "string"
--for k,v in pairs(_G) do
-- print(k, v)
--end
if not table.new then
newtable = function() return {} end
else
newtable = table.new
end
local t = newtable(10000, 500000)
local clock = clock
if os then
clock = os.clock
end
local time = clock()
print("Table creation")
for i = 1, 10000 do
t[i] = i
end
if test == "table" then
for i = 1, 500000 do
t[{i}] = i
end
elseif test == "stringfmt" then
local sfmt = string.format
for i = 1, 500000 do
t[sfmt('%ia', i)] = i
end
elseif test == "string" then
local sfmt = tostring
for i = 1, 500000 do
t[sfmt(i)] = i
end
else
for i = 1, 500000 do
t[i*50] = i
end
end
print("is done in", clock() - time, "sec")
local i = 0
time = clock()
i = 0
print("iteration trough pairs")
time = clock()
for k,v in pairs(t) do
i = i + 1
end
print(i, "done with", clock()-time, "seconds!")
time = clock()
print("cleaning table")
i = 0
if table.clear then
table.clear(t, false)
else
for k,v in pairs(t) do
t[k] = nil
end
end
print("is done with", clock()-time, "seconds!")
print("check is table alive")
print('#=', #t, t[0], t[1], t[2], t.hehe, t.boi)
t.hehe = 1
t.sus = "among"
t["amogus"] = "sus"
t[0] = 300
t[1] = "omegamogus"
print('#=', #t, t[0], t[1], t[2], t.hehe, t.boi, t.sus)
print("done!")