benchmark/index.js
function(callback) {
        var scarlet = new Scarlet(Math.min(opts.n, 100));

        function connect(taskObject) {
            var client = taskObject.task.client;
            var i = taskObject.task.idx;

            client.connect(function() {
                scarlet.taskDone(taskObject);
            });

            client.on("error", function(err) {
                console.log(err + ": Client " + i);
            });
        }

        console.time("Connect");

        // if mode is `clients`, we create (opts.complicating) clients,
        // otherwise we create only one.
        var max = opts["complicating-mode"] === "clients" ? opts.complicating : 1;
        for(var i = 0; i < max; i++) {
            var client = illyria2.createClient("127.0.0.1", SERVER_PORT, {
                runTimeout: 10000,
                retryInterval: 1000,
                reconnect: true
            });

            scarlet.push({ idx: i, client: client }, connect);

            clients.push(client);
        }

        scarlet.afterFinish(max, function() {
            console.timeEnd("Connect");
            callback();
        }, false);
    }
function(callback) {
        var scarlet = new Scarlet(Math.min(opts.n, 100));

        function connect(taskObject) {
            var client = taskObject.task.client;
            var i = taskObject.task.idx;

            client.connect(function() {
                scarlet.taskDone(taskObject);
            });

            client.on("error", function(err) {
                console.log(err + ": Client " + i);
            });
        }

        console.time("Connect");

        // if mode is `clients`, we create (opts.complicating) clients,
        // otherwise we create only one.
        var max = opts["complicating-mode"] === "clients" ? opts.complicating : 1;
        for(var i = 0; i < max; i++) {
            var client = illyria2.createClient("127.0.0.1", SERVER_PORT, {
                runTimeout: 10000,
                retryInterval: 1000,
                reconnect: true
            });

            scarlet.push({ idx: i, client: client }, connect);

            clients.push(client);
        }

        scarlet.afterFinish(max, function() {
            console.timeEnd("Connect");
            callback();
        }, false);
    }
function ( callback ) { var scarlet = new Scarlet ( Math . min ( opts . n , 100 ) ) ; function connect ( taskObject ) { var client = taskObject . task . client ; var i = taskObject . task . idx ; client . connect ( function ( ) { scarlet . taskDone ( taskObject ) ; } ) ; client . on ( "error" , function ( err ) { console . log ( err + ": Client " + i ) ; } ) ; } console . time ( "Connect" ) ; // if mode is `clients`, we create (opts.complicating) clients, // otherwise we create only one. var max = opts [ "complicating-mode" ] === "clients" ? opts . complicating : 1 ; for ( var i = 0 ; i < max ; i ++ ) { var client = illyria2 . createClient ( "127.0.0.1" , SERVER_PORT , { runTimeout : 10000 , retryInterval : 1000 , reconnect : true } ) ; scarlet . push ( { idx : i , client : client } , connect ) ; clients . push ( client ) ; } scarlet . afterFinish ( max , function ( ) { console . timeEnd ( "Connect" ) ; callback ( ) ; } , false ) ; }
step 2.
create clients and connect to server
step 2 . create clients and connect to server