简体   繁体   English

node-inspector / v8-profiler无法开始分析或创建v8日志文件

[英]node-inspector/v8-profiler not starting profiling or creating v8 log file

I have the following nodejs code 我有以下nodejs代码

var profiler = require("v8-profiler");

profiler.startProfiling("FooBar");

doSomethingAsync(function() {
  profiler.stopProfiling("FooBar");
});

I run this: 我运行这个:

$ time node --prof --prof_lazy test/performance/performance-test.js

However I don't get a v8.log file. 但是我没有v8.log文件。

I did have some issues installing the v8-profiler package related to this issue with node-profiler . 使用node-profiler安装与此问题相关的v8-profiler软件包时,确实遇到了一些问题。 I use MacPorts, and g++ defaults to /opt/local/bin/g++ (I use the nodejs package provided from MacPorts as well) I managed to get around the -arch error by using g++ that comes with XCode 我使用MacPorts,并且g ++默认为/ opt / local / bin / g ++(我也使用MacPorts提供的nodejs包),我设法通过使用XCode随附的g ++解决了-arch错误

$ CXX="xcrun g++" npm install v8-profiler

It might be a red herring, but it's worth mentioning incase the resulting v8-profiler binary objects doesn't work with my nodejs install. 这可能是一个红色的鲱鱼,但是值得一提的是,如果生成的v8-profiler二进制对象不适用于我的nodejs安装。

$ node --version
v0.10.22

$ npm --version
1.3.15

You need to add --log option if you want to get a v8.log file. 如果要获取v8.log文件,则需要添加--log选项。

$ node --prof --prof_lazy --log test/performance/performance-test.js

However, when you use v8-profiler, the log file does not contain profiling data. 但是,当您使用v8-profiler时,日志文件不包含概要分析数据。 I guess it is because profiler.stopProfiling() returns the profiling data to the caller. 我猜这是因为profiler.stopProfiling()将分析数据返回给调用者。 See the example in project's README : 请参阅项目的README中的示例:

profiler.startProfiling([name])                   //begin cpu profiling
var cpuProfile = profiler.stopProfiling([name])   //finish cpu profiling

There is another module that allows you to manually start/stop the profiler, while writing the profiling data to v8.log: node-profiler . 还有另一个模块,允许您在将概要分析数据写入v8.log时手动启动/停止探查器: node-profiler I did not manage to get it compiled with Node v0.8 nor v0.10, you may want to fill an issue in the project's issue tracker. 我没有设法用Node v0.8或v0.10编译它,您可能想在项目的问题跟踪器中填充问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM