【问题标题】:Interpreting node.js profile output?解释 node.js 配置文件输出?
【发布时间】:2013-06-26 20:38:41
【问题描述】:

test.js

function test(){
    for(var i=0; i<2000000000; ++i);
};
test();

用于分析它的命令:

node --prof test.js
nprof

输出:

line 249: unknown code state: undefined
line 252: unknown code state: undefined
line 253: unknown code state: undefined
line 256: unknown code state: undefined
line 258: unknown code state: undefined
line 259: unknown code state: undefined
line 260: unknown code state: undefined
line 261: unknown code state: undefined
line 262: unknown code state: undefined
line 263: unknown code state: undefined
line 264: unknown code state: undefined
line 265: unknown code state: undefined
line 266: unknown code state: undefined
(This repeats around 1000 times. I'm removing it from this paste...)

 [Unknown]:
   ticks  total  nonlib   name
     34   79.1%

 [Shared libraries]:
   ticks  total  nonlib   name
      8   18.6%    0.0%  /usr/local/bin/node
      1    2.3%    0.0%  /usr/lib/system/libsystem_kernel.dylib

 [JavaScript]:
   ticks  total  nonlib   name

 [C++]:
   ticks  total  nonlib   name

 [GC]:
   ticks  total  nonlib   name
      0    0.0%

 [Bottom up (heavy) profile]:
  Note: percentage shows a share of a particular caller in the total
  amount of its parent calls.
  Callers occupying less than 2.0% are not shown.

   ticks parent  name
      8   18.6%  /usr/local/bin/node

      1    2.3%  /usr/lib/system/libsystem_kernel.dylib

我期待它在 [JavaScript] 部分显示“测试”功能。为什么没有?

【问题讨论】:

  • 什么版本的节点?使用 0.8.2(例如)我使用您的程序并获得我期望的输出,与我在您的帖子中看到的完全不同。我的输出在这里:pastebin.com/embed_js.php?i=mztwZLfd
  • @Joe,我刚刚在 OSX 上构建的 0.8.2。很奇怪。

标签: javascript node.js debugging profiling


【解决方案1】:

nprof 使用与您所拥有的不同的 v8.log 格式的刻度处理器

我在 node-tick 中拥有相同的 issue(目前与节点 0.8.2 afaik 兼容)。

可能的解决方案:

  • 试试node-tick
  • 尝试以前版本的 nprof (npm install profiler@1.2.0)

或者您可以尝试使用节点版本中的脚本重建 nprof:

  git clone https://github.com/bnoordhuis/node-profile
  git clone https://github.com/joyent/node
  cd node
  git checkout v0.8.7-release # can't see tag for 0.8.2
  cp deps/v8/tools/*.js ../node-profile/tools/v8
  cd ../node-profile
  sh tools/build-nprof

【讨论】:

    猜你喜欢
    • 2017-03-26
    • 2010-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-02
    • 2012-06-13
    • 2019-07-21
    • 1970-01-01
    相关资源
    最近更新 更多