mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-01 02:12:58 +08:00
b57317bdc2
This eliminates the use of shelljs.exec's sync mode, which is the source of the filehandle leaks that can cause EMFILE on OSX, and are CPU-intensive everywhere. Tested locally, needs poking before it gets released.
37 lines
950 B
JavaScript
37 lines
950 B
JavaScript
"use strict";
|
|
|
|
var Q = require("../q");
|
|
|
|
suite("Chaining", function () {
|
|
var numberToChain = 1000;
|
|
|
|
bench("Chaining many already-fulfilled promises together", function (done) {
|
|
var currentPromise = Q();
|
|
for (var i = 0; i < numberToChain; ++i) {
|
|
currentPromise = currentPromise.then(function () {
|
|
return Q();
|
|
});
|
|
}
|
|
|
|
currentPromise.then(done);
|
|
});
|
|
|
|
bench("Chaining and then fulfilling the end of the chain", function (done) {
|
|
var deferred = Q.defer();
|
|
|
|
var currentPromise = deferred.promise;
|
|
for (var i = 0; i < numberToChain; ++i) {
|
|
(function () {
|
|
var promiseToReturn = currentPromise;
|
|
currentPromise = Q().then(function () {
|
|
return promiseToReturn;
|
|
});
|
|
}());
|
|
}
|
|
|
|
currentPromise.then(done);
|
|
|
|
deferred.resolve();
|
|
});
|
|
});
|