mirror of
https://github.com/luau-lang/luau.git
synced 2025-01-10 13:29:09 +00:00
906a00d498
* General - Fix the benchmark require wrapper function to work in Lua - Fix memory leak in the new Luau C API test * New Solver - Luau: type functions should be able to signal whether or not irreducibility is due to an error - Do not generate extra expansion constraint for uninvoked user-defined type functions - Print in a user-defined type function should be reported as an error instead of logging to stdout - Many e-graphs bugfixes and performance improvements - Many general bugfixes and improvements to the new solver as a whole - Fixed issue with Luau used-defined type functions not having all environments initialized - Infer types of globals under new type solver * Fragment Autocomplete - Miscellaneous fixes to make interop with the old solver better * Runtime - Support disabling specific Luau built-in functions from being fast-called or constant-evaluated - Added constant folding for vector arithmetic - Added constant propagation and type inference for Vector3 globals ---------------------------------------------------------- 9 contributors: Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com> Co-authored-by: Daniel Angel <danielangel@roblox.com> Co-authored-by: Jonathan Kelaty <jkelaty@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Varun Saini <vsaini@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
54 lines
1.3 KiB
Lua
54 lines
1.3 KiB
Lua
--[[
|
|
The Great Computer Language Shootout
|
|
http://shootout.alioth.debian.org/
|
|
contributed by Isaac Gouy
|
|
]]
|
|
local function prequire(name) local success, result = pcall(require, name); return success and result end
|
|
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../../bench_support")
|
|
|
|
function test()
|
|
|
|
local function partial(n)
|
|
local a1, a2, a3, a4, a5, a6, a7, a8, a9 = 0, 0, 0, 0, 0, 0, 0, 0, 0;
|
|
local twothirds = 2.0/3.0;
|
|
local alt = -1.0;
|
|
local k2, k3, sk, ck = 0, 0, 0, 0;
|
|
|
|
for k = 1,n do
|
|
k2 = k*k;
|
|
k3 = k2*k;
|
|
sk = math.sin(k);
|
|
ck = math.cos(k);
|
|
alt = -alt;
|
|
|
|
a1 = a1 + math.pow(twothirds,k-1);
|
|
a2 = a2 + math.pow(k,-0.5);
|
|
a3 = a3 + 1.0/(k*(k+1.0));
|
|
a4 = a4 + 1.0/(k3 * sk*sk);
|
|
a5 = a5 + 1.0/(k3 * ck*ck);
|
|
a6 = a6 + 1.0/k;
|
|
a7 = a7 + 1.0/k2;
|
|
a8 = a8 + alt/k;
|
|
a9 = a9 + alt/(2*k -1);
|
|
end
|
|
|
|
return a6 + a7 + a8 + a9;
|
|
end
|
|
|
|
local total = 0;
|
|
local i = 1024
|
|
|
|
while i <= 16384 do
|
|
total = total + partial(i);
|
|
i = i * 2
|
|
end
|
|
|
|
local expected = 60.08994194659945;
|
|
|
|
if (total ~= expected) then
|
|
assert(false, "ERROR: bad result: expected " .. expected .. " but got " .. total);
|
|
end
|
|
|
|
end
|
|
|
|
bench.runCode(test, "math-partial-sums")
|