Hashmap read access Map vs Literal Object

JavaScript performance comparison

Test case created by gartz

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
    const IdType = {
      FOO: Symbol(),
      BAR: Symbol(),
      ZAZ: Symbol()
    }
  
  const mapHashmap = new Map([
    ['FOO', IdType.FOO],
    ['BAR', IdType.BAR],
    ['ZAZ', IdType.ZAZ],
  ]);
  
  const objHashmap = {
    FOO: IdType.FOO,
    BAR: IdType.BAR,
    ZAZ: IdType.ZAZ,
  };
  
  

};
</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
Map
const foo = mapHashmap.get('FOO');
pending…
Literal Object
const foo = objHashmap['FOO'];
pending…

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

0 Comments