Created
October 30, 2013 23:36
-
-
Save dannycoates/7242156 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cluster = require('cluster') | |
var Client = require('../../client') | |
var origin = process.env.PICL_ORIGIN || 'http://127.0.0.1:9000' | |
var password = 'foobar' | |
var threads = 50 | |
if (cluster.isMaster) { | |
console.time('run') | |
var email = 'picltest' + Math.random() + '@example.com' | |
var workers = [] | |
for (var i = 0; i < threads; i++) { | |
workers.push(cluster.fork()) | |
} | |
cluster.on( | |
'online', | |
function (worker) { | |
if (--i === 0) { | |
Client.create(origin, email, password) | |
.done( | |
function () { | |
workers.forEach( | |
function (w) { | |
w.on('message', | |
function (x) { | |
console.log(JSON.stringify(x.length)) | |
if (++i === threads) { | |
console.timeEnd('run') | |
process.exit() | |
} | |
} | |
) | |
w.send(email) | |
} | |
) | |
} | |
) | |
} | |
} | |
) | |
} | |
else { | |
process.on( | |
'message', | |
function (email) { | |
var client = null | |
while (Date.now() % 100 !== 0) {} | |
Client.login(origin, email, password) | |
.then( | |
function (x) { | |
client = x | |
return x.devices() | |
} | |
) | |
.done( | |
function (x) { | |
process.send(x) | |
}, | |
function (err) { | |
process.send(err) | |
} | |
) | |
} | |
) | |
} | |
/*/ | |
getA: client key length 247 is less than the recommended 256 | |
7069636c746573743239406578616d706c652e636f6d | |
7069636c746573743636406578616d706c652e636f6d | |
/*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment