How Can I Ignore Libraries Like Jquery When Profiling Javascript?
Solution 1:
Filtering out libraries is not what you want and AFAIK no profiler does it the way you want it to. Besides, if your code is badly written because it is abusing library calls, you want to see which library calls it is abusing.
Use the built-in Chrome profiler in "Tree (Top Down)" mode. (Select the mode at the bottom of the Self and Total columns.) In this mode you can see the total time each function takes along with the total time spent in each function that function calls and so on down to the leaf functions that call no other functions. So in your function bar()
you will see the total time spent in bar and below that, the total time spent by bar
calling each
and so forth. (Now with jQuery it can get a bit convoluted, but that's not really the point.)
So if you have one function that calls 10 others, and one takes 'forever', the calling function will have a bigger 'total time' and you figure out which of the called functions take the longest by clicking on the triangle and expanding the 'forever' function and looking at the total time of each of the functions it calls. If 9 take little time and 1 takes forever, then that's the culprit and you keep drilling down until you find the problem.
EDIT: A few more tips on using Chrome's profiler
- Use "Heavy (Bottom up)" view to find leaf functions that are taking a lot of time. The triangles display who calls them.
- option-click on a triangle to open the entire tree. Saves lots of clicking through deeply nested call chains.
- "(program)" refers to the part of the time the profiler was running during which no JavaScript was running. Things like rendering the HTML.
You can do filtering and focusing on a per-function basis. Read the documentation for details on this and more.
Solution 2:
Have you tried John Resig's profiler plugin ?
Solution 3:
You could try turning profiling on and off in code using console.profile
and console.profileEnd
. The links are to Firebug documentation, but at least Webkit also supports it. Not sure about IE.
Solution 4:
Using the dynaTrace AJAX Edition, you can exclude a library specified by its URL in the preferences dialog. In the Agent tab, you can give a list of files that should not be traced. So if you list your jquery.js there, you shouldn't see any jquery-related nodes in your PurePaths...
Post a Comment for "How Can I Ignore Libraries Like Jquery When Profiling Javascript?"