开发者

How can I evaluate Dart performance?

开发者 https://www.devze.com 2023-04-12 14:43 出处:网络
Google is launching a new language, promising that it has a better performance, but how can I evaluate performance in Dart source code?

Google is launching a new language, promising that it has a better performance, but how can I evaluate performance in Dart source code?

Let's take as example the "sun flow开发者_StackOverflow中文版er" drawFrame method:

  // Draw the complete figure for the current number of seeds.
  void drawFrame() {
    ctx.clearRect(0, 0, MAX_D, MAX_D);
    for (var i=0; i<seeds; i++) {
      var theta = i * PI2 / PHI;
      var r = Math.sqrt(i) * SCALE_FACTOR;
      var x = xc + r * Math.cos(theta);
      var y = yc - r * Math.sin(theta);
      drawSeed(x,y);
    }
  }

If we have lots of seeds, could we add a statement to evaluate elapsed time within for?


Google promises better performance later on when there is native dart in the browser.

For now Dart compiles directly to JavaScript and is larger and slower than writing pure JavaScript.

The function you have right there is actually identical in pure javascript so the runtime ought to be very nearly the same between compiled dart and a direct javascript version.

You could compare the compiled-to-JS Dart versus JS at jsperf.com if you really wanted to.


There are performance numbers in the GOTO Keynote slides. It appears that Dart is about 2 times slower than V8 at the moment. But this should improve over time according to the Dart team.


Late reply, but just yesterday they announced the performance/benchmarking page which allows you to track performance over time of v8, dart -> js, and the dart vm.

There is a Benchmarking the Dart VM article that tells you how to correctly benchmark the Dart VM.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号