From aba4686f8918ae6168a4737dcfe545afcbf9480d Mon Sep 17 00:00:00 2001 From: i5ting Date: Wed, 20 Apr 2016 16:38:20 +0800 Subject: [PATCH] refact --- Makefile2 | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 6 +++++ run2 | 16 ++++++++++++ 3 files changed, 97 insertions(+) create mode 100755 Makefile2 create mode 100755 run2 diff --git a/Makefile2 b/Makefile2 new file mode 100755 index 0000000..f7e571d --- /dev/null +++ b/Makefile2 @@ -0,0 +1,75 @@ +all: clean test + +test: prepare koa-1 koa-2 koa-2-async express + +report: + @cd logs + @wrk_scan + @echo 'merge logs complete' + +prepare: + @cd koa2 && npm install + @cd .. + @cd other && npm install + @cd .. + @echo 'prepare complete' + + +version: + @node -v + @npm -v + @echo + +koa-1: + @echo 'benchmark koa-1' + @./run2 1 other/koa1.js + @./run2 5 other/koa1.js + @./run2 10 other/koa1.js + @./run2 15 other/koa1.js + @./run2 20 other/koa1.js + @./run2 30 other/koa1.js + @./run2 50 other/koa1.js + @./run2 100 other/koa1.js + @echo + +koa-2: + @echo 'benchmark koa-2' + @./run2 1 koa2/koa2.js + @./run2 5 koa2/koa2.js + @./run2 10 koa2/koa2.js + @./run2 15 koa2/koa2.js + @./run2 20 koa2/koa2.js + @./run2 30 koa2/koa2.js + @./run2 50 koa2/koa2.js + @./run2 100 koa2/koa2.js + @echo + +koa-2-async: + @echo 'benchmark koa-2-async' + @./run2 1 koa2/koa2-async-compile.js + @./run2 5 koa2/koa2-async-compile.js + @./run2 10 koa2/koa2-async-compile.js + @./run2 15 koa2/koa2-async-compile.js + @./run2 20 koa2/koa2-async-compile.js + @./run2 30 koa2/koa2-async-compile.js + @./run2 50 koa2/koa2-async-compile.js + @./run2 100 koa2/koa2-async-compile.js + @echo + +express: + @echo 'benchmark express' + @./run2 1 other/express.js + @./run2 5 other/express.js + @./run2 10 other/express.js + @./run2 15 other/express.js + @./run2 20 other/express.js + @./run2 30 other/express.js + @./run2 50 other/express.js + @./run2 100 other/express.js + @echo + +clean: + @rm -rf koa2/node_modules + @rm -rf other/node_modules + +.PHONY: prepare test \ No newline at end of file diff --git a/README.md b/README.md index c9100f0..0c540ae 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,12 @@ make all make test ``` +查看中间件请求测试 + +``` +make test -f Makefile2 +``` + ## Results ``` diff --git a/run2 b/run2 new file mode 100755 index 0000000..b010e4f --- /dev/null +++ b/run2 @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +echo +MW=$1 node $2 & +pid=$! + +sleep 2 + +wrk 'http://localhost:3333' \ + -d 3 \ + -c 50 \ + -t 8 \ + | grep 'Requests/sec' \ + | awk '{ print " " $2 }' + +kill $pid