Division vs. multiplication

Benchmark created by Solenoid 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*focalLength/z, y: y*focalLength/z};
    }
    
    function fast(x, y, z)
    {
    var k = focalLength/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.