dellingr 0.1.0

An embeddable, pure-Rust Lua VM with precise instruction-cost accounting
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-- Hypothesis: creating a closure inside a hot loop allocates a heap
-- LuaFunction object plus upvalue slots each iteration. Should produce
-- visibly more GC pressure than equivalent inline code.

function _bench()
    local total = 0
    for i = 1, 500 do
        local x = i
        local f = function(y)
            return x + y
        end
        total = total + f(1)
    end
    return total
end

for i = 1, 1000 do _bench() end
print("alloc/closure: true")