Sha256: d71c740bfe66d29fd6293e9eeb0e93c3225abdb3b81e350afa4d7bc637c7fcc0

Contents?: true

Size: 950 Bytes

Versions: 94

Compression:

Stored size: 950 Bytes

Contents

"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();
    });
});

Version data entries

94 entries across 80 versions & 4 rubygems

Version Path
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.5.18 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.5.17 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.5.16 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.5.15 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.5.14 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.5.13 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.5.12 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.5.11 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.5.10 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.5.9 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.5.8 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.5.7 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.5.6 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.5.5 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js
trusty-festivity-extension-2.5.4 node_modules/bower/node_modules/p-throttler/node_modules/q/benchmark/scenarios.js