Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see results of console.profile()?

Tags:

According to Chrome Console API Reference and MDN Docs, using console.profile('label') to start profiling and later using console.endProfile() to end profiling, should result in a profile added to Profiles (has been since renamed to Performance) panel in Chrome.

This works for me in Firefox, but I don't get any profiles when I run my code in Chrome. Instead I get the warning:

DevTools: CPU profile parser is fixing 16 missing samples.

Am I missing something here or is this a bug in Chrome DevTools?

like image 363
atavakoli Avatar asked Mar 27 '18 00:03

atavakoli


People also ask

Where is the console log output?

Steps to Open the Console Log in Google Chrome By default, the Inspect will open the "Elements" tab in the Developer Tools. Click on the "Console" tab which is to the right of "Elements". Now you can see the Console and any output that has been written to the Console log.

What does console profile do?

The console. profile() starts recording a performance profile (for example, the Firefox performance tool). You can optionally supply an argument to name the profile and this then enables you to stop only that profile if multiple profiles being recorded.


2 Answers

Turns out the profile goes into a different panel:

CPU profiles added to the JavaScript profiler panel. You can open it by clicking three dots menu (in the top right corner) ⋮-> More tools -> JavaScript Profiler.

like image 116
atavakoli Avatar answered Sep 19 '22 11:09

atavakoli


The profiling can be observed from below code part.

function profileTest(callback) {          let i = 0;    let work = setInterval(function() {                 if(i == 3) {           callback();           clearInterval(work);                   return;             }        console.log('Doing some work..');        i = i + 1;    }, 1000);       }    console.profile("profileTest()");  profileTest(function(){    console.profileEnd();  });

Note: setInterval is used for simulation purpose.

As @atavakoli have already answered, created profile can be seen in 'CPU PROFILES' part in 'Javascript Profiler' tab that can be opened from Developer Tools → Three dots → More tools. For example below screenshot shows the result profile of above code part.

How to open Javascript Profiler

See following link: https://developers.google.com/web/updates/2016/12/devtools-javascript-cpu-profile-migration

For the warning message, below question link can be referred.
Chrome: CPU profile parser is fixing n missing samples

like image 39
Erdem Savasci Avatar answered Sep 17 '22 11:09

Erdem Savasci