local function fib(n) if n < 2 then return n end return fib(n - 1) + fib(n - 2) end local function loops() local s = 0 for i = 1, 9000000 do s = s + (i % 7) * 3 - (i % 5) end return s end local function floats() local s = 0.0 for i = 1, 3000000 do s = s + 1.0 / (i * 0.5 + 1.0) end return s end local function tables() local t = {} for i = 1, 600000 do t[i] = i * 2 end local s = 0 for i = 1, 600000 do s = s + t[i] end for i = 1, 100 do for j = 1, 100 do s = s + (t[i] or 0) end end return s end local function strings() local parts = {} for i = 1, 150000 do parts[i] = "item" .. i .. "=" .. (i * 3) end local s = 0 for i = 1, #parts do s = s + #parts[i] end return s end local total = 0 total = total + fib(27) total = total + loops() total = total + math.floor(floats()) total = total + tables() total = total + strings() print(string.format("lua-bench checksum=%d", total))