4

I have a complex flow of async/await functions that I would like to optimise.

Using the built-in profiler of Chrome dev tools is practical when debugging synchronous workflows, but tracking micro-tasks triggers to resume promises is a difficult workflow and gives little overview.

Different ideas: I was thinking in the lines of exploiting babel-generated code to gather time spent in different stages of promise resolving, or perhaps using untranspiled code and overriding the global Promise object to gain performance insights.

How can I debug performance of async/await functions in an effective manner?

Karamell
  • 1,023
  • 9
  • 23

1 Answers1

1

After not getting any responses here, I made my own solution. It's very rough, but working. I did this by overriding the global Promise object. This only works for babel-transpiled async functions since native async apparently didn't respect the overridden window.promise. Through stack inspection by using Error().stack (thanks to this question) I could determine who was creating that promise.

The result can be found here and you can use npm i promise-performance

Karamell
  • 1,023
  • 9
  • 23