integer swap

Benchmark created by Honnza on


Description

http://stackoverflow.com/a/14105869/499214

Setup

var a=10;
    var b=20;
    var temp;

Test runner

Ready to run.

Testing in
TestOps/sec
swap with temp
temp = a;
   a = b;
   b = temp;
ready
XOR swap
a ^= b;
b ^= a;
a ^= b;
ready
comma index swap
a = [b][b = a,0];
ready
arithmetic swap
a = a+b;
b = a-b;
a = a-b;
ready

Revisions

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

  • Revision 1: published by Honnza on