Module basic module

Module profiler

Memory profiler module

Instructions:

1
var profiler = require('profiler');

Static function

saveSnapshot

Save a heap snapshot according to the specified name

1
static profiler.saveSnapshot(String fname);

Call parameters:

  • fname : String, heap snapshot name

loadSnapshot

Read a heap snapshot according to the specified name

1
static HeapSnapshot profiler.loadSnapshot(String fname);

Call parameters:

  • fname : String, heap snapshot name

Return result:


takeSnapshot

Get the heap snapshot of the current time node, the heap snapshot records the state of the JS heap at the current moment

1
static HeapSnapshot profiler.takeSnapshot();

Return result:

  • HeapSnapshot , returns a snapshot of the obtained heap information

diff

Execute the given function and compare the changes of 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 result:

  • Object , returns the result of the comparison

start

Start a sampling log of running status

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, specify the sampling time, the default is 1 minute
  • interval : Integer, specify the interval time, the default is 100 milliseconds

Return result:

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

constant

Node_Hidden

Hidden nodes, which can be filtered out when displayed to users

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 the pile

1
const profiler.Node_HeapNumber = 7;

Node_Native

Native objects (not on the v8 heap)

1
const profiler.Node_Native = 8;

Node_Synthetic

Synthetic object

1
const profiler.Node_Synthetic = 9;

Node_ConsString

Concatenated string

1
const profiler.Node_ConsString = 10;

Node_SlicedString

Split string

1
const profiler.Node_SlicedString = 11;

Node_Symbol

Symbol (ES6)

1
const profiler.Node_Symbol = 12;

Node_SimdValue

Sorted SIMD value 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 the array

1
const profiler.Edge_Element = 1;

Edge_Property

Properties of the named object

1
const profiler.Edge_Property = 2;

Edge_Internal

JS inaccessible 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

Point to a node whose space 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;