[英]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). Dart的性能给我留下了深刻印象,我将一个非常简单的Web应用程序组合在一起,以渲染Dart中的Mandelbrot(使用HTML5画布)。 This is by all means not meant as a realistic performance test. 这绝不是一个真实的性能测试。 The page renders the Mandelbrot set in a 800x600 canvas with a max-depth of 10.000. 该页面将Mandelbrot设置为800x600画布,最大深度为10.000。 The app can be seen here: http://goo.gl/DLuQp 该应用程序可以在这里看到: http : //goo.gl/DLuQp
What puzzles me: running in Dartium the image renders in about 8.5 seconds (which is impressive). 令我困惑的是:在Dartium中运行时,图像渲染时间约为8.5秒(令人印象深刻)。 The same page in Firefox takes >15 seconds. Firefox中的同一页面需要> 15秒。 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? 但是在Chrome(版本27.0.1453.93)中运行相同的页面,它不运行Dart但JS版本也在6.7秒内完成,比Dart快?
Why is that so? 为什么会这样?
UPDATE: 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. 另外我添加了一个只有JS的版本(当然是相同的代码)来检查Dartium中的JS。 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. 在Dartium中,JS版本比Dart版本更快。
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. 关闭问题后更新:仅供记录:在这个特定情况下,将代码移动到并行工作者/隔离器不仅导致显着的性能提升,Dart现在明显地将JS版本置于尘埃落后的因素10。
There could be several reasons. 可能有几个原因。 Out of the top of my head: 脱离我的头脑:
It's a known issue with the canvas bindings and APIs. 这是canvas绑定和API的已知问题。 See http://dartbug.com/10344 见http://dartbug.com/10344
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.