Permalink
Browse files

Added `make benchmark` for experimental continuous-benchmarking tool

  • Loading branch information...
1 parent 4d8d5b1 commit e3aabdc2bc568cda96539dc673eaad74f6307c99 @tj tj committed Aug 20, 2011
Showing with 45 additions and 1 deletion.
  1. +4 −1 Makefile
  2. +26 −0 support/app.js
  3. +15 −0 support/bench
View
5 Makefile
@@ -29,7 +29,10 @@ site:
&& cp -fr /tmp/docs/* . \
&& echo "done"
+benchmark:
+ @./support/bench
+
docclean:
rm -f docs/*.{1,html}
-.PHONY: site test test-cov docs docclean
+.PHONY: site test test-cov benchmark docs docclean
View
26 support/app.js
@@ -0,0 +1,26 @@
+
+/**
+ * Module dependencies.
+ */
+
+var express = require('../');
+
+var app = express.createServer();
+
+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('Hello World\n');
+});
+
+app.listen(8000);
View
15 support/bench
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+
+node ./support/app &
+pid=$!
+
+bench() {
+ ab -n 5000 -c 50 -k -q http://local:8000$1 | grep "Requests per" | cut -d ' ' -f 7 | xargs echo "$2:"
+}
+
+sleep .5
+bench / "Hello World"
+bench /json "JSON"
+bench /middleware "Middleware"
+
+kill -9 $pid

0 comments on commit e3aabdc

Please sign in to comment.