Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added `make benchmark` for experimental continuous-benchmarking tool

  • Loading branch information...
commit e3aabdc2bc568cda96539dc673eaad74f6307c99 1 parent 4d8d5b1
TJ Holowaychuk tj authored
Showing with 45 additions and 1 deletion.
  1. +4 −1 Makefile
  2. +26 −0 support/app.js
  3. +15 −0 support/bench
5 Makefile
View
@@ -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
26 support/app.js
View
@@ -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);
15 support/bench
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.