Question

I have the following nodejs code

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.

I did have some issues installing the v8-profiler package related to this issue with node-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

$ 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.

$ node --version
v0.10.22

$ npm --version
1.3.15
Was it helpful?

Solution

You need to add --log option if you want to get a v8.log file.

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

However, when you use v8-profiler, the log file does not contain profiling data. I guess it is because profiler.stopProfiling() returns the profiling data to the caller. See the example in project's 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. 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top