Created
May 12, 2012 09:43
-
-
Save stagas/2665565 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 n = +(process.argv[2] || 10000) | |
var cp = require('child_process') | |
var child = cp.fork(__dirname + '/worker.js') | |
console.log('trying', n, 'messages') | |
var total = n | |
child.on('message', function () { | |
if (!--total) console.log('completed %d roundtrips', n - total) | |
else if (!(total % 1000)) console.log('%d roundtrips', n - total) | |
}) | |
for (var i = n; i--;) { | |
child.send('a') | |
} | |
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 r = 0 | |
process.on('message', function () { | |
process.send('b') | |
if (!(r % 1000)) console.log('received: %d', ++r) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment