Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are Parse, Compile and Evaluate in DevTools Performance tool?

When running JS scripts in Chromes' Performance tab, I see there are three steps for JS interpretation: Parse, Compile and Evaluate. Sometimes I just see Evaluate, sometimes Compile and Evaluate and sometimes it's the whole three.

My questions are:

  • What each step actually means?
  • Why sometimes there are missing steps? (for instance, sometimes Parse is missing)
like image 436
Eliran Pe'er Avatar asked Feb 18 '18 10:02

Eliran Pe'er


People also ask

What is scripting in chrome performance?

The Timeline shows what is going on with your website in each frame. 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.

What is idle time in Chrome performance?

Detects time intervals when user was idle or locked system and displays their durations.


1 Answers

Parse:

The js engine goes over the code, determines all the different scopes, variable declarations etc. and sorts them. At this step also hoisting happens. Basically your plain text sourcecode is turned into an Abstract Syntax Tree (AST)

Compile:

Chromes V8 uses JIT compiling, that means that some parts of the js code are transfered into bytecode (that runs directly on your processor without any layer of abstraction inbetween). This increases performance. Sometimes it may decide to run the code directly without compiling it, e.g. if compiling it takes longer than actually running it unoptimized so there would be no benefit whatsoever.

Evaluating:

The code is run.

Read on:

How V8 optimizes

Bytecode vs. Running directly

All together

like image 172
Jonas Wilms Avatar answered Sep 28 '22 04:09

Jonas Wilms