ShadowNode

Use Node.js in your end devices(QQ: 796448809)

View the Project on GitHub yodaos-project/ShadowNode

Profiler

The profiler module provides memory and CPU profiler methods. It can be accessed using:

var profiler = require('profiler');

profiler.startProfiling()

The profiler.startProfiling(path) method start a CPU profiler, which should be explicitly stopped by profiler.stopProfiling

The profiling data will be stored into a file ${process.cwd()}/Profile-${Date.now()}.

profiler.startProfiling(path)

The profiler.startProfiling(path) method start a CPU profiler, which should be explicitly stopped by profiler.stopProfiling

profiler.startProfiling(duration)

The profiler.startProfiling(duration) method start a CPU profiler, which will stop after duration milliseconds.

The profiling data will be stored into a file ${process.cwd()}/Profile-${Date.now()}.

profiler.startProfiling(path, duration)

The profiler.startProfiling(path, duration) method start a CPU profiler, which will stop after duration milliseconds.

profiler.takeSnapshot([path])

The profiler.takeSnapshot() methd take a Heap profiler file which path is path. If path is not provided, it will be set to ${process.cwd()}/Profile-${Date.now()}

Example

var profiler = require('profiler');
profiler.startProfiling();
balabala...
profiler.stopProfiling();
var profiler = require('profiler');
profiler.startProfiling('/data/profile-123.txt');
balabala...
profiler.stopProfiling();
var profiler = require('profiler');
profiler.startProfiling(1000);
balabala...
var profiler = require('profiler');
profiler.startProfiling('/data/profile-123.txt', 1000);
balabala...
var profiler = require('profiler');
profiler.takeSnapshot();

```js var profiler = require(‘profiler’); profiler.takeSnapshot(‘/data/profile-123.txt’);