43thh34g3hj7j6h43d

JavaScript performance comparison

Test case created by artalar

Preparation code

<script src="https://immutable-js.github.io/immutable-js/immutable.js"></script>
      
<script>
Benchmark.prototype.setup = function() {
  const getSomeShape = () => ({
    _1: Math.random() + '___1',
    _2: '___2' + Math.random(),
    _3: { prop: { deepProp: 'qaz' } }
  })
  
  const objMap = Array.from({length: 99999}).reduce((acc, el, i) =>
    (acc['_' + i] = getSomeShape(), acc),
    {}
  )
  const map = Array.from({length: 99999}).reduce((acc, el, i) =>
    acc.set('_' + i, getSomeShape()),
    new Map()
  )
  const immutableMap = Immutable.Map(objMap)

};
</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
objMap
var objMapNew = {...objMap}
objMapNew['_55'] = getSomeShape()
pending…
map
var mapNew = new Map(map)
mapNew.set('_55', getSomeShape())
pending…
immutable map
immutableMap.set('_55', getSomeShape())
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