Dart code compiled to JS seems to be faster than Dart (in Dartium)


Impressed by the performance of Dart I put together a quite simple web-app to render the Mandelbrot set in Dart (using HTML5 canvas). This is by all means not meant as a realistic performance test. The page renders the Mandelbrot set in a 800×600 canvas with a max-depth of 10.000.
The app can be seen here: http://goo.gl/DLuQp

What puzzles me: running in Dartium the image renders in about 8.5 seconds (which is impressive). The same page in Firefox takes >15 seconds. No surprise there.

But running the same page in Chrome (version 27.0.1453.93), which does not run Dart but the JS version as well completes in 6.7 seconds, faster than Dart?

Why is that so?

I added a “Run” button to re-render the canvas (to verify warm-up behaviour). Also I added a JS-only version (same code of course) to check JS in Dartium. In short: the figures and my question remains as is. Warm-up seems to have no effect. The JS-version is faster in Dartium than the Dart-version.

UPDATE after closed question: Just for the record: in this specific case moving the code into parallel workers/isolates not only resulted in a significant performance boost, also Dart now clearly leaves the JS-version behind in the dust by factor 10.


It’s a known issue with the canvas bindings and APIs. See http://dartbug.com/10344

Answered By – Justin Fagnani

Answer Checked By – Jay B. (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.