Christophe
Christophe

Reputation: 28164

Profiling: how to find out which object a method is attached to?

I have inherited a JavaScript application and I am trying to understand how it works using profiling in Chrome.

Chrome gives me the sequence of methods that are executed, but I only see the method name. How can I find out which object a given method is attached to?

Upvotes: 0

Views: 51

Answers (1)

adamb
adamb

Reputation: 4883

If you want to see the call stack in Chrome dev tools for a specific method, you need to set a break point in the "Sources" panel.

Here's the entire process:

  1. Run "Collect JavaScript CPU" Report
  2. In the functions column, click the right-hand link (of the function in question) to jump to the appropriate source code line
  3. Set a break point on that line
  4. Re-run the script (usually via page refresh)
  5. If break point is hit, call stack will be presented on the right-side column of the "Sources" panel

Upvotes: 1

Related Questions