Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Fast Sqrt 2
Compare Quakes fast inverse squareroot
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 OPR/119.0.0.0
Browser:
Opera 119
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
11 months ago
Test name
Executions per second
Math.sqrt
761630.8 Ops/sec
Quakes fast inverse sqrt.
141052.3 Ops/sec
Script Preparation code:
var i; var r; var v = 2 ** 16; function test1() { for (i = 0; i < 1000; ++i) { r = Math.sqrt(v); } } function test2() { for (i = 0; i < 1000; ++i) { r = Q_rsqrt(v) * v; } } //Based on the fast inverse square root function // https://en.wikipedia.org/wiki/Fast_inverse_square_root // Some original comments preserved for humor value // Designed to try to mimic the original as closely as possible const bytes = new ArrayBuffer(Float32Array.BYTES_PER_ELEMENT); const floatView = new Float32Array(bytes); const intView = new Uint32Array(bytes); const threehalfs = 1.5; function Q_rsqrt(number) { const x2 = number * 0.5; floatView[0] = number; intView[0] = 0x5f3759df - (intView[0] >> 1); let y = floatView[0]; y = y * (threehalfs - (x2 * y * y)); return y; }
Tests:
Math.sqrt
test1();
Quakes fast inverse sqrt.
test2();