Skip to content

Commit

Permalink
test: add router for bench cases (eggjs#78)
Browse files Browse the repository at this point in the history
* test: add router for bench cases

* chore: remove postinstall
  • Loading branch information
fengmk2 authored and dead-horse committed Sep 1, 2016
1 parent 711f9c0 commit 091bf58
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 52 deletions.
1 change: 1 addition & 0 deletions .autod.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
'test/fixtures',
'examples',
'benchmarks',
"docs",
],
devdep: [
'autod',
Expand Down
76 changes: 41 additions & 35 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@

Scene | QPS | Avg RT (ms) | Stdev RT | Max RT
--- | --- | --- | --- | ---
egg Hello World | 8485 | 5.73 | 2.77 | 63.12
koa Hello World | 11852 | 4.23 | 2.99 | 84.56
toa Hello World | 12169 | 4.22 | 2.59 | 39.82
egg nunjucks | 6534 | 7.49 | 4.15 | 96.07
koa nunjucks | 9702 | 5.34 | 5.52 | 145.75
toa nunjucks | 9420 | 5.32 | 2.84 | 52.41
egg Hello World | 8917 | 4.68 | 3.56 | 108.21
koa Hello World | 10709 | 5.02 | 2.74 | 45.41
toa Hello World | 10041 | 5.38 | 2.20 | 47.18
egg nunjucks | 6732 | 7.25 | 4.81 | 257.58
koa nunjucks | 8596 | 6.03 | 6.35 | 162.53
toa nunjucks | 7869 | 6.32 | 3.16 | 59.54

## Default Middleware

- 15 middlewares
- enable router

## Scenes

Expand Down Expand Up @@ -44,11 +49,11 @@ wrk http://10.209.84.139:7002/ -d 10 -c 50 -t 8
Running 10s test @ http://10.209.84.139:7002/
8 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 4.23ms 2.99ms 84.56ms 94.80%
Req/Sec 1.50k 278.02 2.65k 77.36%
119711 requests in 10.10s, 17.92MB read
Requests/sec: 11852.36
Transfer/sec: 1.77MB
Latency 4.68ms 3.56ms 108.21ms 97.60%
Req/Sec 1.35k 270.38 2.86k 79.85%
108162 requests in 10.10s, 16.19MB read
Requests/sec: 10709.54
Transfer/sec: 1.60MB
```

- toa
Expand All @@ -58,10 +63,11 @@ wrk http://10.209.84.139:7003/ -d 10 -c 50 -t 8
Running 10s test @ http://10.209.84.139:7003/
8 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 4.22ms 2.59ms 39.82ms 92.84%
Req/Sec 1.54k 181.11 2.83k 77.09%
122898 requests in 10.10s, 20.63MB read
Requests/sec: 12169.05
Latency 5.02ms 2.74ms 45.41ms 92.83%
Req/Sec 1.27k 140.46 2.59k 82.32%
101410 requests in 10.10s, 17.02MB read
Requests/sec: 10041.10
Transfer/sec: 1.69MB
```

- egg
Expand All @@ -71,11 +77,11 @@ wrk http://10.209.84.139:7001/ -d 10 -c 50 -t 8
Running 10s test @ http://10.209.84.139:7001/
8 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 5.73ms 2.77ms 63.12ms 84.02%
Req/Sec 1.07k 205.02 2.04k 69.40%
85700 requests in 10.10s, 24.11MB read
Requests/sec: 8485.16
Transfer/sec: 2.39MB
Latency 5.38ms 2.20ms 47.18ms 76.67%
Req/Sec 1.13k 219.26 2.56k 69.24%
90065 requests in 10.10s, 25.34MB read
Requests/sec: 8917.43
Transfer/sec: 2.51MB
```

### nunjucks
Expand All @@ -87,11 +93,11 @@ wrk http://10.209.84.139:7002/ -d 10 -c 50 -t 8
Running 10s test @ http://10.209.84.139:7002/
8 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 5.34ms 5.52ms 145.75ms 98.23%
Req/Sec 1.23k 239.23 2.48k 82.69%
97999 requests in 10.10s, 244.96MB read
Requests/sec: 9702.78
Transfer/sec: 24.25MB
Latency 6.03ms 6.35ms 162.53ms 97.93%
Req/Sec 1.09k 220.49 2.71k 82.02%
86825 requests in 10.10s, 217.03MB read
Requests/sec: 8596.56
Transfer/sec: 21.49MB
```

- toa
Expand All @@ -101,11 +107,11 @@ wrk http://10.209.84.139:7003/ -d 10 -c 50 -t 8
Running 10s test @ http://10.209.84.139:7003/
8 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 5.32ms 2.84ms 52.41ms 92.35%
Req/Sec 1.19k 134.30 2.73k 82.92%
95139 requests in 10.10s, 239.53MB read
Requests/sec: 9420.63
Transfer/sec: 23.72MB
Latency 6.32ms 3.16ms 59.54ms 93.03%
Req/Sec 0.99k 116.72 2.05k 80.72%
79487 requests in 10.10s, 200.12MB read
Requests/sec: 7869.66
Transfer/sec: 19.81MB
```

- egg
Expand All @@ -115,9 +121,9 @@ wrk http://10.209.84.139:7001/ -d 10 -c 50 -t 8
Running 10s test @ http://10.209.84.139:7001/
8 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 7.49ms 4.15ms 96.07ms 89.68%
Req/Sec 824.74 175.90 1.75k 67.79%
65988 requests in 10.10s, 173.63MB read
Requests/sec: 6534.15
Transfer/sec: 17.19MB
Latency 7.25ms 4.81ms 257.58ms 92.97%
Req/Sec 0.85k 230.42 2.39k 62.89%
67997 requests in 10.10s, 178.91MB read
Requests/sec: 6732.86
Transfer/sec: 17.72MB
```
7 changes: 5 additions & 2 deletions benchmarks/simple/koa.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
'use strict';

const koa = require('koa');
const router = require('koa-router')();

const app = koa();
let n = 10;
let n = 15;

while (n--) {
app.use(function* (next) {
yield next;
});
}

app.use(function* () {
app.use(router.routes());

router.get('/', function* () {
this.body = 'Hello World, koa';
});

Expand Down
7 changes: 5 additions & 2 deletions benchmarks/simple/toa.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
'use strict';

const toa = require('toa');
const Router = require('toa-router');

const router = new Router();
const app = toa();
let n = 10;
let n = 15;

while (n--) {
app.use(function* (next) {
yield next;
});
}

app.use(function* () {
router.get('/', function* () {
this.body = 'Hello World, toa';
});

app.use(router.toThunk());
console.log('toa app listen on 7003');
app.listen(7003);
7 changes: 5 additions & 2 deletions benchmarks/simple_view/koa.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
const koa = require('koa');
const nunjucks = require('nunjucks');
const path = require('path');
const router = require('koa-router')();

const app = koa();
let n = 10;
let n = 15;

while (n--) {
app.use(function* (next) {
yield next;
});
}

app.use(router.routes());

const options = {
noCache: false,
};
Expand All @@ -31,7 +34,7 @@ function render(name, locals) {
});
}

app.use(function* () {
router.get('/', function* () {
this.body = yield render('home.html', {
user: {
name: 'fookoa',
Expand Down
7 changes: 5 additions & 2 deletions benchmarks/simple_view/toa.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
const toa = require('toa');
const nunjucks = require('nunjucks');
const path = require('path');
const Router = require('toa-router');

const router = new Router();
const app = toa();
let n = 10;
let n = 15;

while (n--) {
app.use(function* (next) {
Expand All @@ -31,7 +33,7 @@ function render(name, locals) {
});
}

app.use(function* () {
router.get('/', function* () {
this.body = yield render('home.html', {
user: {
name: 'footoa',
Expand All @@ -40,5 +42,6 @@ app.use(function* () {
});
});

app.use(router.toThunk());
console.log('toa app listen on 7003');
app.listen(7003);
20 changes: 11 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"egg-onerror": "^0.0.3",
"egg-rest": "^1.0.0",
"egg-schedule": "^2.0.0",
"egg-security": "^1.2.0",
"egg-security": "^1.2.1",
"egg-session": "^0.0.2",
"egg-static": "^0.1.0",
"egg-userrole": "^0.1.0",
Expand Down Expand Up @@ -68,7 +68,14 @@
"estraverse": "^4.1.1",
"formstream": "^1.0.0",
"glob": "^7.0.6",
"hexo": "^3.2.0",
"hexo-generator-index": "^0.2.0",
"hexo-generator-tag": "^0.2.0",
"hexo-renderer-less": "^0.2.0",
"hexo-renderer-marked": "^0.2.10",
"hexo-server": "^0.2.0",
"koa": "^1.2.2",
"koa-router": "^5.4.0",
"merge-descriptors": "^1.0.1",
"moment": "^2.14.1",
"nunjucks": "^2.4.2",
Expand All @@ -80,12 +87,7 @@
"stream-wormhole": "^1.0.0",
"supertest": "^2.0.0",
"toa": "^1.8.10",
"hexo": "^3.2.0",
"hexo-generator-index": "^0.2.0",
"hexo-generator-tag": "^0.2.0",
"hexo-renderer-marked": "^0.2.10",
"hexo-renderer-less": "^0.2.0",
"hexo-server": "^0.2.0"
"toa-router": "^1.5.1"
},
"main": "index.js",
"files": [
Expand All @@ -96,13 +98,13 @@
"index.js"
],
"scripts": {
"postinstall": "test -h docs/node_modules || ln -s ../node_modules docs",
"lint": "eslint --fix lib test examples *.js",
"test": "npm run lint && npm run test-local",
"test-local": "egg-bin test",
"test-examples": "TESTS=examples/**/test/**/*.test.js egg-bin test",
"cov": "egg-bin cov",
"ci": "npm run lint && npm run test-examples && npm run cov",
"doc-init": "test -h docs/node_modules || ln -s ../node_modules docs",
"doc-server": "./scripts/doc.sh server",
"doc-deploy": "./scripts/doc.sh deploy",
"autod": "autod",
Expand All @@ -122,4 +124,4 @@
"ci": {
"version": "4, 6"
}
}
}

0 comments on commit 091bf58

Please sign in to comment.