Local variable due to the scope lookup

Benchmark created on


Setup

var scale = 2,
        img = document.createElement('img'),
        ref_index = 150,
        y, x;
    
    document.body.appendChild(img);
    img.src = uri();
    
    y = img.width / scale;
    y = img.height / scale;
    
    function uri() {
      return "data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7";
    }

Test runner

Ready to run.

Testing in
TestOps/sec
The short version
var index = (Math.floor(y / scale) * img.width + Math.floor(x / scale)) * 4;
ready
The long version
var index = Math.floor(ref_index) * 4;
ready

Revisions

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