feat(benchmark): test middlewares and routing
MODIFY
benchmarks/Makefile
benchmarks/Makefile
-all: middleware
+all: middlewares routing
-middleware:
+routing:
@./run 1 $@
@./run 5 $@
@./run 10 $@
@@ -11,4 +11,15 @@ middleware:
@./run 100 $@
@echo
-.PHONY: all middleware
+middlewares:
+ @./run 1 $@
+ @./run 5 $@
+ @./run 10 $@
+ @./run 15 $@
+ @./run 20 $@
+ @./run 30 $@
+ @./run 50 $@
+ @./run 100 $@
+ @echo
+
+.PHONY: all

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

RENAME
benchmarks/middleware.js
benchmarks/routing.js
const http = require('http');
const { mapTo } = require('rxjs/operators');
const { httpListener, EffectFactory } = require('../packages/core/dist');
-const { logger$ } = require('../packages/middleware-logger/dist');
const n = parseInt(process.env.MW || '1', 10);
@@ -30,6 +29,6 @@ effects.push(
const app = httpListener({ middlewares, effects });
-console.log(` ${n} middlewares -- Marble.js`);
+console.log(` ${n} endpoints -- Marble.js`);
http.createServer(app).listen(1337);

feat(benchmark): test middlewares and routing