{"ScriptPreparationCode":"var i;\r\nvar r;\r\nvar v = 2 ** 16;\r\n\r\nfunction test1() {\r\n for (i = 0; i \u003C 1000; \u002B\u002Bi) {\r\n r = Math.sqrt(v);\r\n }\r\n}\r\n\r\nfunction test2() {\r\n for (i = 0; i \u003C 1000; \u002B\u002Bi) {\r\n r = Q_rsqrt(v) * v;\r\n }\r\n}\r\n\r\n//Based on the fast inverse square root function\r\n// https://en.wikipedia.org/wiki/Fast_inverse_square_root\r\n// Some original comments preserved for humor value\r\n// Designed to try to mimic the original as closely as possible\r\nconst bytes = new ArrayBuffer(Float32Array.BYTES_PER_ELEMENT);\r\nconst floatView = new Float32Array(bytes);\r\nconst intView = new Uint32Array(bytes);\r\nconst threehalfs = 1.5;\r\n\r\nfunction Q_rsqrt(number) {\r\n const x2 = number * 0.5;\r\n floatView[0] = number;\r\n intView[0] = 0x5f3759df - (intView[0] \u003E\u003E 1);\r\n let y = floatView[0];\r\n y = y * (threehalfs - (x2 * y * y));\r\n\r\n return y;\r\n}","TestCases":[{"Name":"Math.sqrt","Code":"test1();","IsDeferred":false},{"Name":"Quakes fast inverse sqrt. ","Code":"test2();","IsDeferred":false}]}