如何分析Mac上的Node.jsconfiguration文件?

我正在使用Node.js 8.3。 而我使用node --prof server.js来分析我的应用程序。 我得到一些像xxxx -v8.log这样的文件。

我试图使用https://www.npmjs.com/package/node-tick-processor和https://github.com/sidorares/node-tick来分析文件。 我有兴趣看到CPUconfiguration文件。

但是输出是这样的,这不是很有帮助:

 [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 65591 59.5% /usr/lib/system/libsystem_kernel.dylib 42621 65.0% /usr/local/bin/node 16632 15.1% /usr/local/bin/node 5544 33.3% /usr/local/bin/node 5888 5.3% /usr/lib/system/libsystem_c.dylib 5875 99.8% /usr/local/bin/node 2702 2.4% /usr/lib/system/libsystem_pthread.dylib 2284 84.5% /usr/local/bin/node [Top down (heavy) profile]: Note: callees occupying less than 0.1% are not shown. inclusive self name ticks total ticks total 68106 61.7% 11088 10.1% /usr/local/bin/node 42617 38.6% 42617 38.6% /usr/lib/system/libsystem_kernel.dylib 5875 5.3% 5875 5.3% /usr/lib/system/libsystem_c.dylib 5548 5.0% 5538 5.0% /usr/local/bin/node 2284 2.1% 2284 2.1% /usr/lib/system/libsystem_pthread.dylib 337 0.3% 337 0.3% /usr/lib/system/libsystem_platform.dylib 303 0.3% 303 0.3% /usr/lib/system/libsystem_malloc.dylib 22970 20.8% 22970 20.8% /usr/lib/system/libsystem_kernel.dylib 418 0.4% 418 0.4% /usr/lib/system/libsystem_pthread.dylib 

有没有其他工具来分析输出文件? 我想看到显示瓶颈function的东西,或者至less为我find行号。 我已经尝试过v8-profiler并且它的输出文件需要在Chrome开发工具上加载。 但是格式看起来不一样。 我不确定我是否仍然能够分析-v8.log文件。

您的工具使用绝对没有问题。 这里的麻烦是,来自named JS函数的CPU消耗的贡献太小而不能在重型configuration文件中看到。 请注意您的个人资料输出中的警告(被占用者less于0.1%,不会显示)。

考虑我的代码:

 var x = 10; function foo() { while (true) { x++; } } foo(); 

这是教授的产出。 正如你所看到的,脚本,函数和行#都是主要的CPU。

  [Unknown]: ticks total nonlib name 13 0.3% [Shared libraries]: ticks total nonlib name 57 1.3% 0.0% /usr/local/bin/node 6 0.1% 0.0% /usr/lib/system/libsystem_kernel.dylib 2 0.0% 0.0% /usr/lib/system/libsystem_platform.dylib 1 0.0% 0.0% /usr/lib/system/libsystem_pthread.dylib 1 0.0% 0.0% /usr/lib/system/libsystem_c.dylib [JavaScript]: ticks total nonlib name 4177 98.1% 99.7% LazyCompile: *foo /Users/gireesh/a.js:2:13 1 0.0% 0.0% Stub: BinaryOpWithAllocationSiteStub [C++]: ticks total nonlib name [GC]: ticks total nonlib name 2 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 4177 98.1% LazyCompile: *foo /Users/gireesh/a.js:2:13 4177 100.0% LazyCompile: *foo /Users/gireesh/a.js:2:13 4177 100.0% Function: ~<anonymous> /Users/gireesh/a.js:1:11 4177 100.0% Function: ~Module._compile module.js:526:37 4177 100.0% Function: ~Module._extensions..js module.js:578:37 4177 100.0% Function: ~Module.load module.js:494:33 

希望这可以帮助。