Search code examples
google-chrome-devtoolsaopprofileroverriding

Can I separate function calls in Chrome Profiler?


I created a library that performs AOP on another Javascript program. The procedure I am taking is the following:

var func_name = func.name.toString();

//new function with the name of original function
window[func_name] = function(){
      ...
      JSLibrary.returnValue = func.apply(this, arguments);
      ...
      return JSLibrary.returnValue
}

The procedure overrides the desired functions by a function that executes additional code before and after the original function is called.

I would like to profile the program so that I can measure my library's timings and then compare results. When I profile the program using Chrome and look under Call Tree, I can see that the new function above is actually being called and it is being referred to as window.(anonymous function) (nothing wrong in that since I know that some of my functions are overriden). But in some cases like the one below, the profiler is grouping the overriden function under one anonymous function (although they were called separately) and the timing represents all the time of the overriden functions added up, because of this I cannot measure the time of every function.

enter image description here

In other words, I would like to ask if there is a way to make the profiler display the called functions in the following structure:

validateRegistration
  window.(anonymous function)
    registerNewAccount
  window.(anonymous function)
    (anonymous)
  window.(anonymous function)
    checkPasswordConfirmation
  window.(anonymous function)
    checkChosenQuestion
  window.(anonymous function)
    (anonymous)

Solution

  • I managed to achieve this, I walked through the timeline and found the separated called functions along with their timings.