bit operator variables

JavaScript performance comparison

Test case created by afishhhhh

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var a = 0b01;
  var b = 0b10;
  var c = 0b00;
  const codes = []
    for (let i = 0; i < 2000; i++) {
      codes.push({
        state: i < 500 ? c : (i < 1200 ? b : a)
      })
    }

};
</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
bit operator
codes.reduce((init, item) => {
  if (item.state == c) {
    init.push((item.state = a, item))
    return init
  }
  return init
}, [])
pending…
bit declare
codes.reduce((init, item) => {
  if (item.state == c) {
    init.push((item.state |= 1, item))
    return init
  }
  return init
}, [])
pending…

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

0 Comments