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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Promise & Deferred Objects in JavaScript: pt.1 Semantics, performance and theory

2 点作者 cwebbdesign大约 12 年前

2 条评论

sprize大约 12 年前
Good stuff! Great tests,...<p>When reading through jQuery's decision to stick with their implementation of promises, a mention of performance considerations piqued my curiosity and I decided to do a quick performance test. I used Benchmark.js and tested the results of creating and resolving a deferred object with a success handler in .then().<p>The results:<p>jQuery 91.6kb When.js 1.04kb Q.js 8.74kb 9,979 ops/sec ±10.22% 96,225 ops/sec ±10.10% 2,385 ops/sec ±3.42% Note: minified with Closure compiler, not gzipped<p>After running these tests, I discovered a much more in-depth test-suite of promise libraries which reveals similar overall results.
sbusse大约 12 年前
Hi Chris,<p>thanks for describing promise/deferred. What i miss though is an explanation, as to why this is better than simple callbacks/events especially in the javascript world.<p>In the end, i have to define callbacks in the promise anyway, so why the whole caboodle in the first place?