找出哪些功能密集使用CPU

Ale*_*lex 6 html javascript jquery dom

我经常使用jQuery,特别是对于像褪色或滑动这样的动画:)

所以我在各种元素上附加了各种函数

$(".fade").each(function(....)

要么

$('*[class*="slide-"]').each(function(...)...

在某些元素上,我使用livequery而不指定事件(因此它会检测在DOM中添加的新元素).

$('*[class*="slide-"]').livequery(function(...

这使用了很多CPU.

无论如何,我要问的是,是否有一个应用程序或其他东西,比如代码分析器,可以告诉我CPU使用了多少这些函数连接到选择器/事件.

Phr*_*ogz 6

Use the Developer Tools in Chrome and Safari, or Firebug for Firefox, and check out the Profiles section. In IE8, press F12 to open its own developer tools and profiling. This question has also been asked, answered, and accepted already on stackoverflow.


Mar*_*ota 2

基于 WebKit 的浏览器(如 Chrome)在开发人员工具中具有 cpu 分析选项卡,可能正是您正在寻找的。