最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Chrome Developer Tools Profiler showing different number of method calls vs console.log - Stack Overflow

programmeradmin1浏览0评论

I'm using the Profiles tab of the Dev Tools in Chrome. In the profile, I'm seeing an entry for function resizeDocument called 6+ times, with values 113ms, 17ms, 45ms, etc etc. Same line number, same file, same everything.

When I log from the console inside resizeDocument function, I only get one entry. What is going on?

I'm using the Profiles tab of the Dev Tools in Chrome. In the profile, I'm seeing an entry for function resizeDocument called 6+ times, with values 113ms, 17ms, 45ms, etc etc. Same line number, same file, same everything.

When I log from the console inside resizeDocument function, I only get one entry. What is going on?

Share Improve this question asked May 28, 2015 at 11:49 sennettsennett 8,45411 gold badges49 silver badges72 bronze badges 1
  • I notice there is an "aggregated total time" there, which is the same in each case. Perhaps there is some internal V8 weirdness happening and the stack trace is getting munged? – sennett Commented May 28, 2015 at 12:15
Add a ment  | 

1 Answer 1

Reset to default 9

The reason of that is the nature of CPU profiler in chrome. It is a sampling profiler. So it collects call stacks (samples) of the running program and uses them for reconstructing the bars in the chart view.

For example if the profiler collected 1000 samples with one call frame for a function 'foo' in the each sample then you will see 1s long bar with 'foo' name in it.

It might happen that the profiler can't collect the next stack trace. For example it happens when the profiler tries to collect the call frames from the stack at a time when the function 'foo' called function 'bar' right before the sample. At this moment, right after call instruction, the function 'bar' constructs the call frame for 'foo' on the stack. So the call frames on the stack are in invalid state at the moment. The profiler detects that and drops the sample. As a result a gap happens in the sequence of stack traces.

In this case two different bars for 'foo' will be constructed.

Also there is a few other reasons when the profiler can't collect the call stack.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论