Created
March 6, 2013 15:56
-
-
Save daguej/5100313 to your computer and use it in GitHub Desktop.
Test performance of Express router vs static first
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 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); |
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 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