Division vs. multiplication (v2)

Revision 2 of this benchmark created by crazy2be on


Description

Tiny performance test to see how much a division costs when projecting 3d points to screen.

Setup

var focalLength = 3.015;
    
    function slow(x, y, z) {
      return {
        x: x / z,
        y: y / z
      };
    }
    
    function fast(x, y, z) {
      var k = 1.0 / z;
      return {
        x: x * k,
        y: y * k
      };
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Slow
slow(3, 5, 7);
slow(3.23, 5.32, 7.01);
ready
Fast
fast(3, 5, 7);
fast(3.23, 5.32, 7.01);
ready

Revisions

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