Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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