The perfectapi benchmark used an actual module that uses perfectapi, namely node-sharedmem. This module was chosen because it has no external dependencies, and has very little logic.
Created
March 16, 2012 17:04
-
-
Save DukeyToo/2051145 to your computer and use it in GitHub Desktop.
Code for benchmarks at http://blog.perfectapi.com/2012/benchmarking-apis-using-perfectapi-vs-express.js-vs-restify.js/
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'); | |
var app = express.createServer(); | |
app.configure(function(){ | |
app.use(express.bodyParser()); | |
}); | |
app.get('/', function(req, res){ | |
res.send('Hello World\n'); | |
}); | |
app.get('/json', function(req, res){ | |
res.send({ name: 'Tobi', role: 'admin' }); | |
}); | |
function foo(req, res, next) { | |
next(); | |
} | |
app.get('/middleware', foo, foo, foo, foo, function(req, res){ | |
res.send('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); | |
}); | |
app.listen(8000); |
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 restify = require('restify'); | |
var server = restify.createServer({ | |
name: 'myapp', | |
}); | |
server.use(restify.queryParser()); | |
server.use(restify.bodyParser()); | |
server.get('/echo/:name', function (req, res, next) { | |
res.send(req.params); | |
return next(); | |
}); | |
server.listen(8000, function () { | |
console.log('%s listening at %s', server.name, server.url); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment