Hi,
I was comparing native Promise performance with goog.Promise
(from
https://closure-library.googlecode.com/git-history/docs/local_closure_goog_promise_promise.js.source.html).
I was surprised that the JS version is much faster, example snippets below.
var testFn = function(constructorFn, allFn) {
var count = 10000;
var promises = new Array(count);
var start = performance.now();
for (var i = 0; i < promises.length; i++) {
promises[i] = new constructorFn(function(res, rej) { res(i); });
};
allFn(promises).then(function() { console.log(performance.now() - start);
});
}
testFn(Promise, Promise.all.bind(Promise)); // ~500ms, binding
necessary because of crbug.com/517668
testFn(Promise, goog.Promise.all); // 600ms
testFn(goog.Promise, Promise.all.bind(Promise)); // ~1500ms
testFn(goog.Promise, goog.Promise.all); // ~85ms
Using both goog.Promise and goog.Promise.all seems much faster than any of
the other three calls where either Promise constructor, or Promise.all
static method is involved. Is there
any room for optimization in native Promises?
Thank you,
Demetrios
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.