Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Add switches to http_simple bench to use domains
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs authored and erikdubbelboer committed Apr 18, 2012
1 parent 01f1719 commit 262c0ba
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion benchmark/http.sh
Expand Up @@ -4,7 +4,9 @@ sudo sysctl -w net.inet.ip.portrange.first=12000
sudo sysctl -w net.inet.tcp.msl=1000
sudo sysctl -w kern.maxfiles=1000000 kern.maxfilesperproc=1000000
ulimit -n 100000

./node benchmark/http_simple.js || exit 1 &
sleep 1
ab -n 30000 -c 100 http://127.0.0.1:8000/bytes/123 | grep Req

ab -n 30000 -c 100 http://127.0.0.1:8000/${TYPE:-bytes}/${LENGTH:-1024} | grep Req
killall node
20 changes: 20 additions & 0 deletions benchmark/http_simple.js
Expand Up @@ -14,7 +14,27 @@ for (var i = 0; i < 20*1024; i++) {
stored = {};
storedBuffer = {};

var useDomains = process.env.NODE_USE_DOMAINS;

// set up one global domain.
if (useDomains) {
var domain = require('domain');
var gdom = domain.create();
gdom.on('error', function(er) {
console.log('Error on global domain', er);
throw er;
});
gdom.enter();
}

var server = http.createServer(function (req, res) {

if (useDomains) {
var dom = domain.create();
dom.add(req);
dom.add(res);
}

var commands = req.url.split("/");
var command = commands[1];
var body = "";
Expand Down

0 comments on commit 262c0ba

Please sign in to comment.