Skip to content

Instantly share code, notes, and snippets.

@daguej
Created March 6, 2013 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daguej/5100313 to your computer and use it in GitHub Desktop.
Save daguej/5100313 to your computer and use it in GitHub Desktop.
Test performance of Express router vs static first
var express = require('express')
, app = express();
app.use(function(req, res, next) {
var t = Date.now(), end = res.end;
res.end = function() {
end.apply(this, arguments);
console.log(req.path, Date.now() - t);
};
next();
});
app.use(app.router);
app.use(express.static(__dirname));
app.get('/test.html', function(req, res) {
res.end('ok');
});
app.listen(9999);
var express = require('express')
, app = express();
app.use(function(req, res, next) {
var t = Date.now(), end = res.end;
res.end = function() {
end.apply(this, arguments);
console.log(req.path, Date.now() - t);
};
next();
});
app.use(express.static(__dirname));
app.use(app.router);
app.get('/test.html', function(req, res) {
res.end('ok');
});
app.listen(9999);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment