Created
July 22, 2011 19:21
-
-
Save 3rd-Eden/1100205 to your computer and use it in GitHub Desktop.
Handshake benchmark
This file contains hidden or 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 io = require('../').listen(8080) | |
| , child = require('child_process'); | |
| io.sockets.on('connection', function () { | |
| // nothing to do there as we are testing the handshake clean up. | |
| }); | |
| // Check every 1 sec to see howmany ghost handshakes are allocated | |
| var count = 0 | |
| , check = setInterval(function () { | |
| count = Object.keys(io.handshaken).length; | |
| console.log('#' + count + ' handshakes allocated'); | |
| }, 1000); | |
| console.log('Listening on port 8080'); | |
| // Start the apache benchmark test, and -r to ignore the errors | |
| var ab = child.spawn('ab', [ | |
| '-n', 2500 | |
| , '-c', 10 | |
| , '-r' | |
| , 'http://127.0.0.1:8080/socket.io/1/' | |
| ]); | |
| ab.stdout.on('data', function (data) { | |
| console.log(data.toString()); | |
| }); | |
| ab.stderr.on('data', function (err) { | |
| console.error(err.toString()); | |
| }); | |
| ab.on('exit', function () { | |
| // wait for the one more sweep | |
| setTimeout(function () { | |
| console.log('Test ' + (count === 0 ? 'finished successfully' : 'failed')); | |
| clearInterval(check); | |
| io.server.close(); | |
| }, 40000); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment