sqrt vs fast inverse sqrt (v7)

Revision 7 of this benchmark created on


Setup

var y = new Float32Array(1);
    var i = new Int32Array(y.buffer);
    var fastInvSqrt_typed = function(n) {
      var n2 = n * 0.5;
      y[0] = n;
      i[0] = 0x5f375a86 - (i[0] >> 1);
      n = y[0];
      return n * (1.5 - (n2 * n * n));
    };

Test runner

Ready to run.

Testing in
TestOps/sec
Math.sqrt
1/Math.sqrt(Math.random());
ready
fast inverse sqrt
fastInvSqrt_typed(Math.random());
ready
Pow 0.5
Math.pow(Math.random(), -0.5);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.