File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -28,14 +28,27 @@ let heapStackDepth = 0;
28
28
/*
29
29
* Collects a heap profile when heapProfiler is enabled. Otherwise throws
30
30
* an error.
31
+ *
32
+ * Data is returned in V8 allocation profile format.
31
33
*/
32
- export function profile ( ignoreSamplePath ?: string , sourceMapper ?: SourceMapper ) :
33
- perftools . profiles . IProfile {
34
+ export function v8Profile ( ) : AllocationProfileNode {
34
35
if ( ! enabled ) {
35
36
throw new Error ( 'Heap profiler is not enabled.' ) ;
36
37
}
38
+ return getAllocationProfile ( ) ;
39
+ }
40
+
41
+ /**
42
+ * Collects a profile and returns it serialized in pprof format.
43
+ * Throws if heap profiler is not enabled.
44
+ *
45
+ * @param ignoreSamplePath
46
+ * @param sourceMapper
47
+ */
48
+ export function profile ( ignoreSamplePath ?: string , sourceMapper ?: SourceMapper ) :
49
+ perftools . profiles . IProfile {
37
50
const startTimeNanos = Date . now ( ) * 1000 * 1000 ;
38
- const result = getAllocationProfile ( ) ;
51
+ const result = v8Profile ( ) ;
39
52
// Add node for external memory usage.
40
53
// Current type definitions do not have external.
41
54
// TODO: remove any once type definition is updated to include external.
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ export const heap = {
34
34
start : heapProfiler . start ,
35
35
stop : heapProfiler . stop ,
36
36
profile : heapProfiler . profile ,
37
+ v8Profile : heapProfiler . v8Profile ,
37
38
} ;
38
39
39
40
// If loaded with --require, start profiling.
You can’t perform that action at this time.
0 commit comments