swap array vs variable (v28)

Revision 28 of this benchmark created on


Setup

var a = 1,
        b = 2;

Teardown


    if (a+b !== 3) {
      throw Error();
    }
  

Test runner

Ready to run.

Testing in
TestOps/sec
array
b = [a, a = b][0];
ready
variable
var c = a;

a = b;
b = c;
ready
bit
a = a ^ b;
b = a ^ b;
a = a ^ b;
ready
tmp
a = (_=b,b=a,_);
ready
function
b = (function (x){ return x; })(a, a = b)
ready

Revisions

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