Skip to content

Instantly share code, notes, and snippets.

@ngot
Created July 24, 2017 10:17
Show Gist options
  • Save ngot/1c0f6019f3d2c3708322665f8df7b145 to your computer and use it in GitHub Desktop.
Save ngot/1c0f6019f3d2c3708322665f8df7b145 to your computer and use it in GitHub Desktop.
雪崩 Booom!
const compose = require('koa-compose');
const mids = [];
for (var i = 0; i < 20; i++) {
mids.push(async (context, next) => {
await next();
});
}
var fn = compose(mids);
var ctx = {};
console.time('bench');
for (var j = 0; j < 650000; j++) {
fn(ctx).then(() => {}).catch(e => console.log(e));
}
console.timeEnd('bench');
@OpenGG
Copy link

OpenGG commented Jul 25, 2017

async-await 消耗内存很厉害哇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment