Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding marks to Chrome's Timeline tool?

Tags:

Sometimes, it's difficult to tell when a piece of code starts and when it ends. Is it possible to add markers to Chrome's Timeline tool?

like image 417
Leo Jiang Avatar asked Jan 06 '14 01:01

Leo Jiang


People also ask

How do I use the Chrome Performance tab?

To access the Performance tab, navigate to the website you want to profile, then open Chrome DevTools by right-clicking and selecting Inspect. Select the Performance tab inside Chrome DevTools. The easiest way to capture a performance profile is by clicking the Start profiling and reload page icon.

What is scripting in chrome performance?

To be able to visually identify what was going on when you profiled your website, Timeline is painted in different colors. JavaScript execution time is marked in yellow and it's called Scripting. The purple area shows the Rendering and the green parts of the Timeline show the Painting process.

What is idle time in Chrome performance?

This is idle time, the time when the browser is waiting on the CPU or GPU to do some processing. It is shown in the pie chart screenshot in the documentation page How to Use the Timeline Tool.


2 Answers

Use console.timeStamp(markName). See https://developers.google.com/web/tools/chrome-devtools/debug/console/track-executions#marking-the-timeline for reference.

like image 156
nrabinowitz Avatar answered Nov 02 '22 00:11

nrabinowitz


console.time() and console.timeEnd() now show under Performance's Console section (next to Main, GPU, Network, etc.).

For example:

console.time('Hello world!');
console.time('Hi world!');
setTimeout(() => console.timeEnd('Hello world!'), 1000);
setTimeout(() => console.timeEnd('Hi world!'), 2000);

This looks like this:

enter image description here

like image 39
kiewic Avatar answered Nov 02 '22 00:11

kiewic