Performance of Assigning variables in JavaScript (v7)

Revision 7 of this benchmark created on


Description

http://stackoverflow.com/q/8624939/

Replaced location with locatio for the test.

Setup

var posX = 0,
                posY = 0,
                lastPosX = 0,
                lastPosY = 0,
    ev = drag;

Test runner

Ready to run.

Testing in
TestOps/sec
if-elseif
// async test
if(ev === 'drag') {
                        posX = ev + lastPosX;
            posY = ev + lastPosY;
                } else {
                        lastPosX = posX;
                        lastPosY = posY;
                }
ready
Switch
// async test
switch(ev) {
            case 'drag':
                        posX = ev + lastPosX;
                        posY = ev + lastPosY;
                break;

                        case 'dragend':
                                lastPosX = posX;
                                lastPosY = posY;
                                break;
        }
ready

Revisions

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