title: Best way to test performance of Express.js handler?
body: <p>I'm building an app using Express.js, pug, and mongoose. I have a lot of handlers that makes multiple async db queries using await. In an effort to gauge roughly how long these handlers will take to complete, and also how long each of the awaits will block the event loop, I've added the blocked-at library which prints the time in Ms each time the event loop is blocked. Given a handler like this:</p>
  
  <pre><code>Const handler = async (req, res, next) =&gt; {
      Const data1 = await getData1().exec()
      // Do something
      const data2 = await getData2().exec()
      // Do something with data1 and data2
      const data3 = await getData3().exec()
      // Do something with data1, data2, and data3
  }
  </code></pre>
  
  <p>I will see a single output from the blocked at function like:
      Blocked for 734.22 Ms"</p>
  
  <p>This is confusing, because I would expect to see 3 separate entries, one for each await call as it is called, then registers it's callback and then returns to the event loop. Its my understanding that using async calls like that do not block the event loop until the end of the handler function, but this output suggests otherwise. If my understanding is correct, what is the best way to accurately gauge what is going on in the event loop in handlers like this that may grow large over time?</p>
  
  <p>Also, nearly one second seems like quite a long time for the event loop to be blocked to fetch some data and do a bit of business logic. Are there any strategies to speed this up?</p>