Skip to content

the Map implementation in dart2js is 3 times slower than JS version #28210

Closed
@jumperchen

Description

@jumperchen

For example,

The dart version will take about 2738 ms in my environment.

import 'dart:collection';
void main() {
  var m1 = {};
  var s = new DateTime.now().microsecondsSinceEpoch;
  for (var i = 0; i < 1000000; i++) {    
    var m2 = {};
    m1[i] = m2;
    m2[i] = i;
  }
  print(new DateTime.now().microsecondsSinceEpoch - s);
}

The pure JS version will take about 813 ms only.

var s = new Date().getTime();
var m1 = {};
 for (var i = 0; i < 1000000; i++) {    
    var m2 = {};
    m1[i] = m2;
    m2[i]  = i;
 }
console.log(new Date().getTime() - s);

I also tested the dart version in dart VM, it takes the same as the pure JS version.
So, it seems no way for us to optimize the Map creation to speed up the performance in browser environment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.web-dart2js

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions