Module basic module

module profiler

Memory profiler module

Instructions:

1
var profiler = require('profiler');

static function

getHeapCodeStatistics

Get = statistics about the code in the v8 heap and its metadata

1
static Object profiler.getHeapCodeStatistics();

Return results:

  • Object, returns statistical information of metadata

getHeapSpaceStatistics

Get detailed usage of v8 heap memory

1
static Array profiler.getHeapSpaceStatistics();

Return results:

  • Array, returns the detailed usage of heap memory

getHeapStatistics

Get v8 heap memory usage statistics

1
static Object profiler.getHeapStatistics();

Return results:

  • Object, returns statistics on heap memory usage

saveSnapshot

Save a heap snapshot under the specified name

1
static profiler.saveSnapshot(String fname);

Call parameters:

  • fname: String, heap snapshot name

loadSnapshot

Read a heap snapshot based on the specified name

1
static HeapSnapshot profiler.loadSnapshot(String fname);

Call parameters:

  • fname: String, heap snapshot name

Return results:


takeSnapshot

Obtain the heap snapshot of the current time node. The heap snapshot records the status of the JS heap at the current moment.

1
static HeapSnapshot profiler.takeSnapshot();

Return results:

  • HeapSnapshot, returns the obtained heap information snapshot

diff

Execute the given function and compare the changes in the v8 heap before and after execution

1
static Object profiler.diff(Function test);

Call parameters:

  • test: Function, given the function to be tested

Return results:

  • Object, returns the comparison result

start

Start a running status sampling log

1 2 3
static Timer profiler.start(String fname, Integer time = 60000, Integer interval = 100);

Call parameters:

  • fname: String, given log storage file name
  • time: Integer, specifies the sampling time, the default is 1 minute
  • interval: Integer, specify the interval time, the default is 100 milliseconds

Return results:

  • Timer, returns the sampling timer, you can stop sampling early through the clear method

constant

Node_Hidden

Hidden nodes that can be filtered out when displayed to the user

1
const profiler.Node_Hidden = 0;

Node_Array

array

1
const profiler.Node_Array = 1;

Node_String

string

1
const profiler.Node_String = 2;

Node_Object

JS objects (except strings and arrays)

1
const profiler.Node_Object = 3;

Node_Code

compiled code

1
const profiler.Node_Code = 4;

Node_Closure

function closure

1
const profiler.Node_Closure = 5;

Node_RegExp

regular expression

1
const profiler.Node_RegExp = 6;

Node_HeapNumber

Sorted numbers in a heap

1
const profiler.Node_HeapNumber = 7;

Node_Native

Native object (non-v8 heap)

1
const profiler.Node_Native = 8;

Node_Synthetic

Synthetic object

1
const profiler.Node_Synthetic = 9;

Node_ConsString

concatenated strings

1
const profiler.Node_ConsString = 10;

Node_SlicedString

split string

1
const profiler.Node_SlicedString = 11;

Node_Symbol

Symbols (ES6)

1
const profiler.Node_Symbol = 12;

Node_SimdValue

Sorted SIMD values ​​in the heap (ES7)

1
const profiler.Node_SimdValue = 13;

Edge_ContextVariable

variables in functions

1
const profiler.Edge_ContextVariable = 0;

Edge_Element

elements in array

1
const profiler.Edge_Element = 1;

Edge_Property

Properties of named objects

1
const profiler.Edge_Property = 2;

Edge_Internal

JS cannot enter the link

1
const profiler.Edge_Internal = 3;

Edge_Hidden

Point to the node whose space size needs to be calculated in advance

1
const profiler.Edge_Hidden = 4;

Edge_Shortcut

Points to a node whose space size cannot be calculated in advance

1
const profiler.Edge_Shortcut = 5;

Edge_Weak

a weak reference (ignored by GC)

1
const profiler.Edge_Weak = 6;