Jun*_*r M 7 performance performance-testing web dart
Google推出了一种新语言,承诺它具有更好的性能,但我如何评估Dart源代码的性能呢?
我们以" 太阳花 "drawFrame方法为例:
// 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);
}
}
Run Code Online (Sandbox Code Playgroud)
如果我们有很多seeds,我们可以添加一个声明来评估其中的经过时间for吗?
谷歌承诺更好的性能,对后来当在浏览器的本地镖.
目前Dart直接编译为JavaScript,并且比编写纯JavaScript更大更慢.
你在那里的功能在纯javascript中实际上是相同的,所以运行时应该在编译的dart和直接的javascript版本之间几乎相同.
如果你真的想要,你可以在jsperf.com上比较编译到JS Dart和JS.