Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I evaluate Dart performance?

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 flower" 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?

like image 913
Junior Mayhé Avatar asked Oct 10 '11 19:10

Junior Mayhé


1 Answers

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.

like image 77
Simon Sarris Avatar answered Sep 27 '22 21:09

Simon Sarris