Finding bottlenecks in javascript?

2020-03-11 03:07发布

I'm attempting to find a bottleneck in my Javascript. Basically I'm developing a chrome extension written in Javascript which is taking 4-5 seconds to perform a task. There's a lot of code involved in the task and using print statements / chrome built in dev tools just isnt working. The dev tools don't seem to even see my Javascript running. I'm wondering if anyone has any advice / tools they think could be of benefit?

4条回答
啃猪蹄的小仙女
2楼-- · 2020-03-11 03:07

I remember Google Chrome has a built-in JavaScript profiler. Or can't you use this for your extension? (I have never built Chrome extensions.)

查看更多
老娘就宠你
3楼-- · 2020-03-11 03:18

Open your page in Chrome.

Tools -> Developer tools -> Profiles

Start Profiling (3rd button, grey circle on the status bar at the bottom)

查看更多
ゆ 、 Hurt°
4楼-- · 2020-03-11 03:27

You can try to use Profiler as it was mentioned before or Timeline. Timeline will help you if the time was spent in native code.

查看更多
够拽才男人
5楼-- · 2020-03-11 03:34

Perhaps it'd be a good idea to open the HTML files in Firefox instead of letting Chrome extensions handle it. That'd allow you to use Firebug to determine any causes, which would be very helpful.

查看更多
登录 后发表回答