diff --git a/benchmarks/Makefile b/benchmarks/Makefile index baf0d6f..46d0690 100644 --- a/benchmarks/Makefile +++ b/benchmarks/Makefile @@ -1,13 +1,26 @@ -all: - @./run 1 middleware - @./run 5 middleware - @./run 10 middleware - @./run 15 middleware - @./run 20 middleware - @./run 30 middleware - @./run 50 middleware - @./run 100 middleware +all: middleware experimental + +middleware: + @./run 1 $@ + @./run 5 $@ + @./run 10 $@ + @./run 15 $@ + @./run 20 $@ + @./run 30 $@ + @./run 50 $@ + @./run 100 $@ @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 diff --git a/benchmarks/experimental/async.js b/benchmarks/experimental/async.js new file mode 100644 index 0000000..5dc568c --- /dev/null +++ b/benchmarks/experimental/async.js @@ -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); diff --git a/benchmarks/experimental/index.js b/benchmarks/experimental/index.js new file mode 100644 index 0000000..84a3198 --- /dev/null +++ b/benchmarks/experimental/index.js @@ -0,0 +1,6 @@ +// support async await by babel +require('babel/register')({ + optional: ['asyncToGenerator'] +}); + +require('./async');