Integer maps

JavaScript performance comparison

Test case created by mikolalysenko

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  function randInt () {
    return Math.round((Math.random() - 0.5) * (1 << 30))
  }
  
  function generateInts (count) {
    var result = []
    for (var i = 0; i < count; ++i) {
      result.push(randInt())
    }
    return result
  }
  
  var keys = generateInts(10000)
  var vals = generateInts(10000)

};
</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
Object
var map = {}
for (var i = 0; i < keys.length; ++i) {
  map[keys[i]] = vals[i]
}
pending…
Holey array
var map = new Array()
for (var i = 0; i < keys.length; ++i) {
  map[keys[i]] = vals[i]
}
pending…
ES6 Map
var map = new Map()
for (var i = 0; i < keys.length; ++i) {
  map.set(keys[i], vals[i])
}
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