When profiling my JavaScript with FireBug, functions like jQuery.clone() stands for almost 50% of the consumed time:
Function | call| % | own | time | avg | min | max | file
_____________________________________________________________________________
clone | 400 | 42% | 840ms | 1332ms | 3s | 0.1ms | 13.ms | jquery.min.js
clone | 138 | 13% | 267ms | 1038ms | 7ms | 5ms | 16.ms | jquery.min.js
template | 338 | 6% | 125ms | 185ms | 0.5ms| 0.2ms | 1.6ms | underscore.js
fadeImage | 398 | 3% | 79ms | 146ms | 0.8ms| 0.1ms | 2.7ms | ondemand.js
I am not calling clone() my self, and I have problems understanding why it is called that often. I have a backbone.js app with a lot of subviews – that could be a reason – but thats just guessing.
Is there a way to profile not only how often a call is made, but also how it was triggered?
If you use firebug for debugging its possible to use console.trace() which outputs the stacktrace. So you can see which function has called this function.