feature - added benchmark scripts
ADD
benchmarks/Makefile
+all: middleware
+
+middleware:
+ @./run 1 $@
+ @./run 5 $@
+ @./run 10 $@
+ @./run 15 $@
+ @./run 20 $@
+ @./run 30 $@
+ @./run 50 $@
+ @./run 100 $@
+ @echo
+
+.PHONY: all middleware

ADD
benchmarks/middleware.js
+const http = require('http');
+const { mapTo, filter } = require('rxjs/operators');
+const { httpListener, matchPath, matchType } = require('../dist');
+
+const n = parseInt(process.env.MW || '1', 10);
+
+const root$ = request$ => request$
+ .pipe(
+ matchPath('/'),
+ matchType('GET'),
+ mapTo({})
+ );
+
+const middleware$ = request$ => request$
+ .pipe(
+ filter(req => 1 + 1 === 2)
+ );
+
+const middlewares = [];
+const effects = [root$];
+
+for (let i = 0; i < n; i++) {
+ middlewares.push(middleware$);
+}
+
+const app = httpListener({ middlewares, effects });
+
+console.log(` ${n} middlewares`);
+http.createServer(app).listen(1337);

ADD
benchmarks/run
+#!/usr/bin/env bash
+
+echo
+MW=$1 node $2 &
+pid=$!
+
+sleep 2
+
+wrk 'http://localhost:1337' \
+ -d 3 \
+ -c 50 \
+ -t 8 \
+ | grep 'Requests/sec' \
+ | awk '{ print " " $2 }'
+
+kill $pid

MODIFY
package.json
package.json
"start": "npm run watch",
"clean": "rimraf dist",
"build": "npm run clean && tsc",
+ "prebench": "npm run build",
+ "bench": "make -C benchmarks",
"example": "ts-node example/index.ts",
"example:watch": "nodemon --watch src --watch example --ext ts --ignore '*.spec.ts' --exec npm run example",
"watch": "tsc -w",

feature - added benchmark scripts