Fastest swap (v2)

Revision 2 of this benchmark created on


Setup

let a = 1;
let b = 2;

Test runner

Ready to run.

Testing in
TestOps/sec
De-structuring swap
[a, b] = [b, a];
ready
temp var swap
let temp = a;

a = b;
b = temp;
ready
XOR swap
a ^= b;
b ^= a;
a ^= b;
ready

Revisions

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