add experimental to benchmark
This commit is contained in:
parent
1c5cb6f691
commit
c021b4610d
3 changed files with 55 additions and 10 deletions
|
@ -1,13 +1,26 @@
|
||||||
|
|
||||||
all:
|
all: middleware experimental
|
||||||
@./run 1 middleware
|
|
||||||
@./run 5 middleware
|
middleware:
|
||||||
@./run 10 middleware
|
@./run 1 $@
|
||||||
@./run 15 middleware
|
@./run 5 $@
|
||||||
@./run 20 middleware
|
@./run 10 $@
|
||||||
@./run 30 middleware
|
@./run 15 $@
|
||||||
@./run 50 middleware
|
@./run 20 $@
|
||||||
@./run 100 middleware
|
@./run 30 $@
|
||||||
|
@./run 50 $@
|
||||||
|
@./run 100 $@
|
||||||
@echo
|
@echo
|
||||||
|
|
||||||
.PHONY: all
|
experimental:
|
||||||
|
@./run 1 $@
|
||||||
|
@./run 5 $@
|
||||||
|
@./run 10 $@
|
||||||
|
@./run 15 $@
|
||||||
|
@./run 20 $@
|
||||||
|
@./run 30 $@
|
||||||
|
@./run 50 $@
|
||||||
|
@./run 100 $@
|
||||||
|
@echo
|
||||||
|
|
||||||
|
.PHONY: all middleware experimental
|
||||||
|
|
26
benchmarks/experimental/async.js
Normal file
26
benchmarks/experimental/async.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
|
||||||
|
var http = require('http');
|
||||||
|
var koa = require('../..');
|
||||||
|
var app = koa();
|
||||||
|
|
||||||
|
app.experimental = true;
|
||||||
|
|
||||||
|
// number of middleware
|
||||||
|
|
||||||
|
var n = parseInt(process.env.MW || '1', 10);
|
||||||
|
console.log(' %s async middleware', n);
|
||||||
|
|
||||||
|
while (n--) {
|
||||||
|
app.use(async function (next){
|
||||||
|
await next;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var body = new Buffer('Hello World');
|
||||||
|
|
||||||
|
app.use(async function (next){
|
||||||
|
await next;
|
||||||
|
this.body = body;
|
||||||
|
});
|
||||||
|
|
||||||
|
app.listen(3333);
|
6
benchmarks/experimental/index.js
Normal file
6
benchmarks/experimental/index.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
// support async await by babel
|
||||||
|
require('babel/register')({
|
||||||
|
optional: ['asyncToGenerator']
|
||||||
|
});
|
||||||
|
|
||||||
|
require('./async');
|
Loading…
Reference in a new issue