Script
Script
bit = bit32
local benchmarks = {
{Name="Array3d",
Func= function()
local function array_set(self, x, y, z, p)
assert(x >= 0 and x < self.nx, "x outside PA")
assert(y >= 0 and y < self.ny, "y outside PA")
assert(z >= 0 and z < self.nz, "z outside PA")
local pos = (z*self.ny + y)*self.nx + x
local image = self.image
if self.packed then
local maxv = self.max_voltage
if p > maxv then self.max_voltage = p*2.0 end
local oldp = image[pos] or 0.0 -- Works with uninitialized table, too
if oldp > maxv then p = p + maxv*2.0 end
image[pos] = p
else
image[pos] = p
end
self.changed = true
self.changed_recently = true
end
return run_iter(200)
end
},
{
Name="binarytrees",
Func= function()
local MIN_DEPTH = 4
local MAX_DEPTH = 12
local EXPECT_CKSUM = -10914
do
local stretchdepth = maxdepth + 1
local stretchtree = BottomUpTree(0, stretchdepth)
check = check +ItemCheck(stretchtree)
end
for depth=mindepth,maxdepth,2 do
local iterations = 2 ^ (maxdepth - depth + mindepth)
for i=1,iterations do
check = check + ItemCheck(BottomUpTree(1, depth)) +
ItemCheck(BottomUpTree(-1, depth))
end
end
return run_iter(3)
end
},
{
Name="coroutines",
Func= function()
local poolsize = 503
local threads = {}
local id = 1
local token = 0
local ok
return run_iter(3300000)
end
},
{
Name="euler",
Func= function()
function run_iter(N)
local cache, m, n = { 1 }, 1, 1
for i=2,N do
local j = i
for len=1,1000000000 do
j = bit32.bor(bit32.band(bit32.rshift(j,1), bit32.band(j,1)-1),
bit32.band(bit32.lshift(j,1)+j+1, bit32.bnot(bit32.band(j,1)-1)))
if cache then
local x = cache[j]; if x then j = x+len; break end
elseif j == 1 then
j = len+1; break
end
end
if cache then cache[i] = j end
if j > m then m, n = j, i end
end
assert(m > 1 and n > 1)
end
return run_iter(3500000)
end
}
}
if not v then
print(" [+]: Benchmark failed, is your exploit shit?")
else