Here is my javascript code, it is pretty simple:
console.profile();
var count = 1000;
var fn1 = function () {
for (var i = 0; i < count; i++) {
console.log("THIS IS FN1");
}
}
var fn2 = function () {
for (var i = 0; i < count; i++) {
console.log("THIS IS FN2");
}
fn1();
}
fn2();
console.profileEnd();
and this is my profile screenshot:
Why there are some gap in the image, just like my black rectangle marked?
What does this gap mean?
log
calls on the top offn2
. However, sincelog
calls take almost no time and since profiling data are sampled you end up with some calls being merged into one block and others being missed. You can increase sampling interval by turning on "High resolution CPU profiling" in the DevTools settings. You should then get something like this: i.imgur.com/E67WWqX.png . However, it still doesn't explain whyf2
is splitted into couple of blocks even though is called only once.