Division vs. multiplication

JavaScript performance comparison

Revision 2 of this test case created by crazy2be

Info

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

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    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
      };
    }
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Slow
slow(3, 5, 7);
slow(3.23, 5.32, 7.01);
pending…
Fast
fast(3, 5, 7);
fast(3.23, 5.32, 7.01);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment