Skip to content

Instantly share code, notes, and snippets.

@brendangregg
Created May 3, 2016 20:46
Show Gist options
  • Save brendangregg/169b9d7df91ab344bd9766c754805f21 to your computer and use it in GitHub Desktop.
Save brendangregg/169b9d7df91ab344bd9766c754805f21 to your computer and use it in GitHub Desktop.
load-server.js
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