sqrt vs fast inverse sqrt (v4)

Revision 4 of this benchmark created on


Setup

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

Test runner

Ready to run.

Testing in
TestOps/sec
Math.sqrt
Math.sqrt(23428937);
ready
fast inverse sqrt
fastInvSqrt_typed(23428937);
ready

Revisions

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