Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Roblox
GitHub Repository: Roblox/luau
Path: blob/master/bench/gc/test_GC_hashtable_Keyval.lua
2725 views
1
local function prequire(name) local success, result = pcall(require, name); return success and result end
2
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")
3
4
function test()
5
local t = {}
6
7
local max = 10000
8
local iters = 50000
9
10
for i = 1,iters do
11
local is = tostring(i)
12
local input = string.rep(is, 1000 / #is)
13
14
t[is] = input
15
16
-- remove old entries
17
if i > max then
18
t[tostring(i - max)] = nil
19
end
20
end
21
end
22
23
bench.runCode(test, "GC: hashtable keys and values")
24
25