Count functions calls with JavaScript

后端 未结 4 348
傲寒
傲寒 2021-01-21 12:16

For example: I have a lot of functions and use them many times. I need to count calls for each function. What is the best practice to make it?

At first i thought i need

4条回答
  •  情歌与酒
    2021-01-21 12:42

    The best way is to use a profiler.

    On IE: press F12 to open developer tools, then go to the Profiler tab, and hit the play button. After stopping the profiler, you'll be presented with a lot of info (number of calls for each function, inclusive time, exclusive time, etc.)

    On Chrome: press F12, go to Profiles, Collect JavaScript CPU Profile (that won't tell you the number of calls though)

提交回复
热议问题