Key lookup small set

JavaScript performance comparison

Test case created by danahartweg

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var dataSet = new Set(['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']);
  var dataArray = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty'];
  var dataObject = { one: true, two: true, three: true, four: true, five: true, six: true, seven: true, eight: true, nine: true, ten: true, eleven: true, twelve: true, thirteen: true, fourteen: true, fifteen: true, sixteen: true, seventeen: true, eighteen: true, nineteen: true, twenty: true };
  
  var lookup1 = 'one';
  var lookup2 = 'eleven';
  var lookup3 = 'twenty';

};
</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
Set.has
dataSet.has(lookup1);
dataSet.has(lookup2);
dataSet.has(lookup3);
pending…
Array.includes
dataArray.includes(lookup1);
dataArray.includes(lookup2);
dataArray.includes(lookup3);
pending…
Array.indexOf
dataArray.indexOf(lookup1);
dataArray.indexOf(lookup2);
dataArray.indexOf(lookup3);
pending…
Object key
dataObject[lookup1];
dataObject[lookup2];
dataObject[lookup3];
pending…
Object.hasOwnProperty
dataObject.hasOwnProperty(lookup1);
dataObject.hasOwnProperty(lookup2);
dataObject.hasOwnProperty(lookup3);
pending…

Compare results of other browsers

Revisions

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

0 Comments