indexed maps vs arrays

JavaScript performance comparison

Test case created by Gerhard Gradnig

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  let set = new Set();
  
  for(let i = 0; i < 10; i++) {
    set.add({x: i*4});
  }
  
  let arr = [];
  
  for(let i = 0; i < 10; i++) {
    arr.push({x: i*4});
  }
  

};
</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
let res = [];
for(let item of set) {
  if(item.x % 16 == 0)
    res.push(item);
}
pending…
Array
let res = arr.filter(i => i.x % 16 == 0);
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