when performance profiling in chrome anonymous high-use functions are difficult to trouble-shoot when they are listed at the root of the call tree. is there a way to determ
You can utilize console.profile([label])
, console.profileEnd()
, console.time([label])
, console.timeEnd([label])
.
For example, execute the below in the JS snippet in console then review the anonynous function
execution profile under 'Customize and control DevTools > More tools > JavaScript Profile'.
console.profile("anonymous function");
console.time("anonymous function");
(function() {
var a = 123;
function abc() {
return a
}
abc();
}());
console.timeEnd("anonymous function");
console.profileEnd();
TIP: Storing JS in DevTools Snipets: Select Sources
-> Snippets
-> right-click -> select New
-> place javascript
within middle panel -> highlight / select text of javascript
within middle panel -> right-click -> select Evaluate in Console
-> click right-triangle at right panel or Ctrl+Enter
.