module profiler
memory profiler module
Instructions:
1var profiler = require('profiler');
static function
getHeapCodeStatistics
get=statistics of the code in the v8 heap and its metadata
1static Object profiler.getHeapCodeStatistics();
Return result:
- Object, returns the statistics of the metadata
getHeapSpaceStatistics
Get detailed usage of v8 heap memory
1static Array profiler.getHeapSpaceStatistics();
Return result:
- Array, returns the detailed usage of heap memory
getHeapStatistics
Get statistics on v8 heap memory usage
1static Object profiler.getHeapStatistics();
Return result:
- Object, returns statistics on heap memory usage
saveSnapshot
Save a heap snapshot with the specified name
1static profiler.saveSnapshot(String fname);
Call parameters:
- fname: String, heap snapshot name
loadSnapshot
Read a heap snapshot by the specified name
1static HeapSnapshot profiler.loadSnapshot(String fname);
Call parameters:
- fname: String, heap snapshot name
Return result:
- HeapSnapshot, returns the read heap snapshot
takeSnapshot
Get the heap snapshot of the current time node, the heap snapshot records the state of the JS heap at the current moment
1static HeapSnapshot profiler.takeSnapshot();
Return result:
- HeapSnapshot, returns the obtained snapshot of heap information
diff
Execute the given function and compare the changes in the v8 heap before and after execution
1static Object profiler.diff(Function test);
Call parameters:
- test: Function, given the function to test
Return result:
- Object, returns the result of the comparison
start
Start a running status sampling log
1
2
3static Timer profiler.start(String fname,
Integer time = 60000,
Integer interval = 100);
Call parameters:
- fname: String, the 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 the user
1const profiler.Node_Hidden = 0;
Node_Array
array
1const profiler.Node_Array = 1;
Node_String
string
1const profiler.Node_String = 2;
Node_Object
JS objects (except strings and arrays)
1const profiler.Node_Object = 3;
Node_Code
compiled code
1const profiler.Node_Code = 4;
Node_Closure
function closure
1const profiler.Node_Closure = 5;
Node_RegExp
regular expression
1const profiler.Node_RegExp = 6;
Node_HeapNumber
sorted numbers in heap
1const profiler.Node_HeapNumber = 7;
Node_Native
Native objects (on the non-v8 heap)
1const profiler.Node_Native = 8;
Node_Synthetic
Synthetic object
1const profiler.Node_Synthetic = 9;
Node_ConsString
concatenated string
1const profiler.Node_ConsString = 10;
Node_SlicedString
split string
1const profiler.Node_SlicedString = 11;
Node_Symbol
Notation (ES6)
1const profiler.Node_Symbol = 12;
Node_SimdValue
Sorted SIMD values in the heap (ES7)
1const profiler.Node_SimdValue = 13;
Edge_ContextVariable
variable in function
1const profiler.Edge_ContextVariable = 0;
Edge_Element
elements in the array
1const profiler.Edge_Element = 1;
Edge_Property
properties of named objects
1const profiler.Edge_Property = 2;
Edge_Internal
Links that JS can't enter
1const profiler.Edge_Internal = 3;
Edge_Hidden
Point to the node that needs to calculate the space size in advance
1const profiler.Edge_Hidden = 4;
Edge_Shortcut
Points to a node whose size cannot be calculated in advance
1const profiler.Edge_Shortcut = 5;
Edge_Weak
a weak reference (ignored by the GC)
1const profiler.Edge_Weak = 6;