bitwise XOR vs ternary

JavaScript performance comparison

Test case created by samonela

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  const arr = [[1,1,0,0],[1,0,0,1],[0,1,1,1],[1,0,1,0]];

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
ternary
const flipAndInvertImage = A => A
    .map(x => x.reverse())
    .map(x => x.map(i => i ? 0 : 1));


flipAndInvertImage(arr);
pending…
bitwise
const flipAndInvertImage = A => A
    .map(x => x.reverse())
    .map(x => x.map(i => i ^ 1));

flipAndInvertImage(arr);
pending…

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

Compare results of other browsers

0 Comments