1. async function responseTime(ctx, next) {
    2. const start = new Date();
    3. await next();
    4. const ms = new Date() - start;
    5. ctx.set("X-Response-Time", ms + "ms");
    6. }
    1. async function respond(ctx, next) {
    2. await next();
    3. if ("/" != ctx.url) return;
    4. ctx.body = "Hello World";
    5. }

    加上log4js可统计每个资源和请求的耗时