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 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0
Browser:
Firefox 136
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Math.sqrt
167047.0 Ops/sec
Quakes fast inverse sqrt.
63387.6 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();