Created
May 3, 2016 20:46
-
-
Save brendangregg/169b9d7df91ab344bd9766c754805f21 to your computer and use it in GitHub Desktop.
load-server.js
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 http = require('http'); | |
var conns = 0; | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('G\'Day\n'); | |
conns++; | |
}).listen(8199, '0.0.0.0'); | |
function status(interval) { | |
setTimeout(function() { | |
console.log('Connections/sec: ' + conns / interval); | |
conns = 0; | |
status(interval); | |
}, interval * 1000); | |
} | |
console.log('Listening at http://127.0.0.1:8199/'); | |
if (process.argv.length > 2) { | |
var interval = process.argv[2]; | |
console.log('Summary every ' + interval + ' secs'); | |
status(interval); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment