koajs / koa

Expressive middleware for node.js using ES2017 async functions
https://koajs.com
MIT License
35.11k stars 3.22k forks source link

feat: support asyncLocalStorage #1721

Closed fengmk2 closed 1 year ago

fengmk2 commented 1 year ago

pick from https://github.com/koajs/koa/pull/1455 pick from https://github.com/koajs/koa/pull/1718

Checklist

codecov[bot] commented 1 year ago

Codecov Report

Base: 99.60% // Head: 99.61% // Increases project coverage by +0.00% :tada:

Coverage data is based on head (a30f869) compared to base (d36e5f7). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## v2.x #1721 +/- ## ======================================= Coverage 99.60% 99.61% ======================================= Files 5 5 Lines 508 520 +12 Branches 143 145 +2 ======================================= + Hits 506 518 +12 Misses 2 2 ``` | [Impacted Files](https://codecov.io/gh/koajs/koa/pull/1721?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=koajs) | Coverage Δ | | |---|---|---| | [lib/application.js](https://codecov.io/gh/koajs/koa/pull/1721/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=koajs#diff-bGliL2FwcGxpY2F0aW9uLmpz) | `98.47% <100.00%> (+0.15%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=koajs). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=koajs)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

fengmk2 commented 1 year ago
> make -C benchmarks

  1 middleware 
  35897.62

  5 middleware 
  35746.13

  10 middleware 
  35301.83

  15 middleware 
  35013.68

  20 middleware 
  34659.48

  30 middleware 
  34392.32

  50 middleware 
  32751.03

  100 middleware 
  32041.21

  1 async middleware 
  34012.71

  5 async middleware 
  35437.67

  10 async middleware 
  34759.20

  15 async middleware 
  33877.35

  20 async middleware 
  32487.66

  30 async middleware 
  31547.37

  50 async middleware 
  26018.91

  100 async middleware 
  25044.55

  1 async middleware with asyncLocalStorage
  25236.60

  5 async middleware with asyncLocalStorage
  28190.28

  10 async middleware with asyncLocalStorage
  27993.33

  15 async middleware with asyncLocalStorage
  28634.36

  20 async middleware with asyncLocalStorage
  25402.22

  30 async middleware with asyncLocalStorage
  25973.56

  50 async middleware with asyncLocalStorage
  22281.10

  100 async middleware with asyncLocalStorage
  16808.98
fengmk2 commented 1 year ago

https://github.com/koajs/koa/tree/benchmark-v2.x

fengmk2 commented 1 year ago

2.14.0