TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

ES6 Performance

64 点作者 g4k将近 10 年前

10 条评论

fenomas将近 10 年前
The trouble with microbenchmarks like these is, JS engines nowadays are often clever enough to simply eliminate the code being tested, or change its character enough that the results are no longer meaningful. Vyacheslav Egorov (a chrome v8 engineer) has written a bunch of very good blogs on this. E.g.<p><a href="http:&#x2F;&#x2F;mrale.ph&#x2F;blog&#x2F;2014&#x2F;02&#x2F;23&#x2F;the-black-cat-of-microbenchmarks.html" rel="nofollow">http:&#x2F;&#x2F;mrale.ph&#x2F;blog&#x2F;2014&#x2F;02&#x2F;23&#x2F;the-black-cat-of-microbenchm...</a><p><a href="http:&#x2F;&#x2F;mrale.ph&#x2F;blog&#x2F;2012&#x2F;12&#x2F;15&#x2F;microbenchmarks-fairy-tale.html" rel="nofollow">http:&#x2F;&#x2F;mrale.ph&#x2F;blog&#x2F;2012&#x2F;12&#x2F;15&#x2F;microbenchmarks-fairy-tale.h...</a><p>Checking the tests here, the &quot;default parameters&quot; section shows some tests being 2000x faster than others, which sounds suspicious. Here&#x27;s an es5 test case:<p><pre><code> function fn(arg, other) { arg = arg === undefined ? 1 : arg; other = other === undefined ? 3 : other; return other; } test(function() { fn(); fn(2); fn(2, 4); }); </code></pre> Sure enough, an arbitrarily smart VM could compile that code down to `test();`. How much this and other optimizations affect each test is anyone&#x27;s guess, but I think it&#x27;s likely that at least some of these results are dominated by coincidental features of how the tests are written.
评论 #9828422 未加载
评论 #9828138 未加载
dgreensp将近 10 年前
TLDR, use Babel in &quot;loose&quot; mode and you&#x27;ll be fine for pretty much all the ES6 syntax features (by which I exclude Maps, Sets, and generators). Most of the features listed are zero-overhead when transpiled this way. As usual, the native implementations are much slower for some reason (probably because they aren&#x27;t optimized yet).<p>Microbenchmarks and relative speeds are not super useful. I&#x27;m a performance nut and I love optimizing code -- back in the day I wrote a syntax-highlighting editor that was snappy in IE6&#x27;s crappy JScript engine -- but I&#x27;m not going to worry that some syntax feature is 3x or even 10x slower than assigning to a local variable (which is what, one CPU instruction?). If you&#x27;re that concerned, you should be avoiding object allocations ({}) like the plague, and that is just madness except in really performance-critical sections of code (and games).
joshstrange将近 10 年前
There might be some great information here but it&#x27;s completely unreadable. Add some borders on your table, It&#x27;s impossible to read in it&#x27;s current state.
ahoge将近 10 年前
Interesting data, poor presentation.<p>The tables need some formatting and colors would be nice, too. Instead of &quot;slower&quot; and &quot;faster&quot; it should be just a factor. So, 2x would mean that it takes twice as long and 0.5x would mean that it&#x27;s twice as fast.<p>Also, what&#x27;s the baseline? Where does that 1x come from?
inglor将近 10 年前
Promises - the assumption here is that native promises are fast - this is amusing. Userland implementations like Bluebird promises are significantly faster than native promises. Not to mention the fact that converting an API to use promises is slow with native promises - a native `promisify` will have to be provided for Node, it&#x27;s being worked on.
评论 #9827363 未加载
评论 #9828911 未加载
skosch将近 10 年前
Super interesting, and somewhat disappointing as well.<p>Also — off topic, but I really wish they&#x27;d provided graphs, or at least given those tables some formatting love. Does anyone know of similar benchmarks that have?
评论 #9827053 未加载
评论 #9826834 未加载
sonnyp将近 10 年前
See <a href="http:&#x2F;&#x2F;kpdecker.github.io&#x2F;six-speed&#x2F;" rel="nofollow">http:&#x2F;&#x2F;kpdecker.github.io&#x2F;six-speed&#x2F;</a> for overview and better readability.
haberman将近 10 年前
Wow, this is all a bit disheartening to read the day after I spent all day updating my app to ES6 + babel.<p>These performance hits are extreme. I would never have guessed that so many of these features are taking 20-2000x speed hits.<p>I hope the browsers and V8 catch up soon so transpiling ES6 is no longer necessary.
评论 #9827356 未加载
评论 #9827250 未加载
vander_elst将近 10 年前
tables not formatted!!!!!!!
marvel_boy将近 10 年前
Add some borders to the tables, the presentation is horrible