Of course, Firebug, Chrome's Web Inspector, Opera's Dragonfly and dynaTrace's AJAX tools for IE have profiling capabilities. However, I haven't found a tool that lets me 'ignore' a library.
To give an example, suppose I have the following pure JS/DOM code:
function foo(node) {
for (var i = 0; i < node.childNodes.length; i++) {
node.childNodes[i].innerHTML = 'Test';
}
}
and a similar bit of code that uses jQuery:
function bar(jqNode) {
jqNode.children().each(function() {
$(this).html('Test');
});
}
(examples aren't exactly great code, please leave them be as that isn't the point)
If you throw both through a JS profiler, you'll find that in the first example, there's just one function where the 'own time' of the function equals the 'total' time spent in the function - as the DOM manipulations get counted as 'own time'.
In the jQuery example, however, all of this is abstracted away into jQuery, which means the 'own time' is minimal and all the time is spent in jQuery.
This makes it very hard to find performance bottlenecks, because the functions with the highest 'own time' are jQuery.fix
and jQuery.init
and such (which doesn't tell me anything about how well-written (or not) my code is), and the functions with the highest 'total time' are usually too high up the call stack to find out where the actual problem is (if you have one function that calls 10 others, and one takes 'forever', the calling function will have a bigger 'total time' but that won't let you figure out which of the called functions take the longest').