DEV Community

Discussion on: Which JS loop is fast?

Collapse
 
rouilj profile image
John P. Rouillard

Which JS interpreter are you using? Is it possible it's running a JIT optimize step as part of the first run that is reflected in the
subsequent runs?

Collapse
 
shubhamtiwari909 profile image
Shubham Tiwari

I am using node js for running these

Collapse
 
rouilj profile image
John P. Rouillard

Ok, so V8. So suspect the answer to your question:

While running the loop first time in every case the time
taken is higher compared to other 9 test case, please
mention the reason in the comment section if you know that.

is probably the JIT compiler/optimizer:

blog.logrocket.com/how-javascript-...

Thread Thread
 
shubhamtiwari909 profile image
Shubham Tiwari

Thank i will read this