-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c5cb6f
commit c021b46
Showing
3 changed files
with
55 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
experimental: | ||
@./run 1 $@ | ||
@./run 5 $@ | ||
@./run 10 $@ | ||
@./run 15 $@ | ||
@./run 20 $@ | ||
@./run 30 $@ | ||
@./run 50 $@ | ||
@./run 100 $@ | ||
@echo | ||
|
||
.PHONY: all | ||
.PHONY: all middleware experimental |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// support async await by babel | ||
require('babel/register')({ | ||
optional: ['asyncToGenerator'] | ||
}); | ||
|
||
require('./async'); |