local function spawnNow callback local bindable Instance new BindableE

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
local function spawnNow(callback, ...)
local bindable = Instance.new("BindableEvent")
bindable.Event:Connect(callback)
bindable:Fire(...)
bindable:Destroy()
end
local function f() end
local t1 = tick()
for _ = 1, 10000 do
spawnNow(f, 123)
end
print("fast spawn", tick()-t1)
local t2 = tick()
for iteration = 1, 10000 do
coroutine.wrap(f)(123)
end
print("coroutine wrap", tick()-t2)