2013-06-29 26 views
2

test.js解释node.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

什么版本的节点?使用0.8.2(例如)我使用你的程序,并得到我期望的输出,而不像我在帖子中看到的那样。我的输出在这里:http://pastebin.com/embed_js.php?i=mztwZLfd – Joe

+0

@Joe,0.8.2我刚刚建立在OSX上。奇怪的。 – MaiaVictor

回答

2

nprof采用剔处理器从你有什么我有在node-tick相同issue(这是目前与节点0.8.2 AFAIK兼容)

不同v8.log格式。

可能的解决方案:

,或者你可以尝试重建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