Fastest swap

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
De-structuring swap
let a = 1;
let b = 2;

[a, b] = [b, a];
ready
temp var swap
let a = 1;
let b = 2;
let temp = a;

a = b;
b = temp;
ready
XOR swap
let a = 1;
let b = 2;

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.