Bitwise key

Benchmark created on


Preparation HTML

<script>
  const COMPONENT_TYPES = {
  	card: 1,
  	cardHolder: 2
  }

  var obj1 = {key: 'Card-101'};
  var obj2 = {type: 'Card', index: 101};
  var obj3 = {key: (COMPONENT_TYPES.card << 16) | 101};
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Current
obj1.key.split('-')[0] === 'Card'
ready
Seperate values
obj2.type === 'Card'
ready
Bit Wise
obj3.key >> 16 === COMPONENT_TYPES.card
ready

Revisions

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