@datadog/pprof 3.0.0-pre-19d5e87 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/src/heap-profiler-bindings.js +24 -1
- package/out/src/heap-profiler-bindings.js.map +1 -1
- package/out/src/index.d.ts +8 -3
- package/out/src/index.js +33 -7
- package/out/src/index.js.map +1 -1
- package/out/src/profile-encoder.js +2 -2
- package/out/src/profile-encoder.js.map +1 -1
- package/out/src/profile-serializer.d.ts +2 -10
- package/out/src/profile-serializer.js +17 -55
- package/out/src/profile-serializer.js.map +1 -1
- package/out/src/sourcemapper/sourcemapper.js +32 -7
- package/out/src/sourcemapper/sourcemapper.js.map +1 -1
- package/out/src/time-profiler-bindings.d.ts +1 -0
- package/out/src/time-profiler-bindings.js +2 -1
- package/out/src/time-profiler-bindings.js.map +1 -1
- package/out/src/time-profiler.d.ts +13 -5
- package/out/src/time-profiler.js +63 -43
- package/out/src/time-profiler.js.map +1 -1
- package/out/src/v8-types.d.ts +1 -39
- package/package.json +17 -33
- package/prebuilds/darwin-arm64/node-102.node +0 -0
- package/prebuilds/darwin-arm64/node-108.node +0 -0
- package/prebuilds/darwin-arm64/node-111.node +0 -0
- package/prebuilds/darwin-arm64/node-115.node +0 -0
- package/prebuilds/darwin-arm64/node-72.node +0 -0
- package/prebuilds/darwin-arm64/node-79.node +0 -0
- package/prebuilds/darwin-arm64/node-83.node +0 -0
- package/prebuilds/darwin-arm64/node-88.node +0 -0
- package/prebuilds/darwin-arm64/node-93.node +0 -0
- package/prebuilds/darwin-x64/node-102.node +0 -0
- package/prebuilds/darwin-x64/node-108.node +0 -0
- package/prebuilds/darwin-x64/node-111.node +0 -0
- package/prebuilds/darwin-x64/node-115.node +0 -0
- package/prebuilds/darwin-x64/node-72.node +0 -0
- package/prebuilds/darwin-x64/node-79.node +0 -0
- package/prebuilds/darwin-x64/node-83.node +0 -0
- package/prebuilds/darwin-x64/node-88.node +0 -0
- package/prebuilds/darwin-x64/node-93.node +0 -0
- package/prebuilds/linux-arm/node-102.node +0 -0
- package/prebuilds/linux-arm/node-108.node +0 -0
- package/prebuilds/linux-arm/node-111.node +0 -0
- package/prebuilds/linux-arm/node-115.node +0 -0
- package/prebuilds/linux-arm/node-72.node +0 -0
- package/prebuilds/linux-arm/node-79.node +0 -0
- package/prebuilds/linux-arm/node-83.node +0 -0
- package/prebuilds/linux-arm/node-88.node +0 -0
- package/prebuilds/linux-arm/node-93.node +0 -0
- package/prebuilds/linux-arm64/node-102.node +0 -0
- package/prebuilds/linux-arm64/node-108.node +0 -0
- package/prebuilds/linux-arm64/node-111.node +0 -0
- package/prebuilds/linux-arm64/node-115.node +0 -0
- package/prebuilds/linux-arm64/node-72.node +0 -0
- package/prebuilds/linux-arm64/node-79.node +0 -0
- package/prebuilds/linux-arm64/node-83.node +0 -0
- package/prebuilds/linux-arm64/node-88.node +0 -0
- package/prebuilds/linux-arm64/node-93.node +0 -0
- package/prebuilds/linux-ia32/node-72.node +0 -0
- package/prebuilds/linux-ia32/node-79.node +0 -0
- package/prebuilds/linux-x64/node-102.node +0 -0
- package/prebuilds/linux-x64/node-108.node +0 -0
- package/prebuilds/linux-x64/node-111.node +0 -0
- package/prebuilds/linux-x64/node-115.node +0 -0
- package/prebuilds/linux-x64/node-72.node +0 -0
- package/prebuilds/linux-x64/node-79.node +0 -0
- package/prebuilds/linux-x64/node-83.node +0 -0
- package/prebuilds/linux-x64/node-88.node +0 -0
- package/prebuilds/linux-x64/node-93.node +0 -0
- package/prebuilds/linuxmusl-x64/node-102.node +0 -0
- package/prebuilds/linuxmusl-x64/node-108.node +0 -0
- package/prebuilds/linuxmusl-x64/node-111.node +0 -0
- package/prebuilds/linuxmusl-x64/node-115.node +0 -0
- package/prebuilds/linuxmusl-x64/node-72.node +0 -0
- package/prebuilds/linuxmusl-x64/node-79.node +0 -0
- package/prebuilds/linuxmusl-x64/node-83.node +0 -0
- package/prebuilds/linuxmusl-x64/node-88.node +0 -0
- package/prebuilds/linuxmusl-x64/node-93.node +0 -0
- package/prebuilds/win32-ia32/node-102.node +0 -0
- package/prebuilds/win32-ia32/node-72.node +0 -0
- package/prebuilds/win32-ia32/node-79.node +0 -0
- package/prebuilds/win32-ia32/node-83.node +0 -0
- package/prebuilds/win32-ia32/node-88.node +0 -0
- package/prebuilds/win32-ia32/node-93.node +0 -0
- package/prebuilds/win32-x64/node-102.node +0 -0
- package/prebuilds/win32-x64/node-108.node +0 -0
- package/prebuilds/win32-x64/node-111.node +0 -0
- package/prebuilds/win32-x64/node-115.node +0 -0
- package/prebuilds/win32-x64/node-72.node +0 -0
- package/prebuilds/win32-x64/node-79.node +0 -0
- package/prebuilds/win32-x64/node-83.node +0 -0
- package/prebuilds/win32-x64/node-88.node +0 -0
- package/prebuilds/win32-x64/node-93.node +0 -0
- package/out/src/cpu-profiler-bindings.d.ts +0 -1
- package/out/src/cpu-profiler-bindings.js +0 -23
- package/out/src/cpu-profiler-bindings.js.map +0 -1
- package/out/src/cpu-profiler.d.ts +0 -19
- package/out/src/cpu-profiler.js +0 -99
- package/out/src/cpu-profiler.js.map +0 -1
- package/scripts/require-package-json.js +0 -33
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-profiler.js","sourceRoot":"","sources":["../../ts/src/time-profiler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG
|
|
1
|
+
{"version":3,"file":"time-profiler.js","sourceRoot":"","sources":["../../ts/src/time-profiler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;AAEH,kDAA0B;AAE1B,6DAA0D;AAE1D,qEAGkC;AAGlC,MAAM,EAAC,YAAY,EAAC,GAAG,kCAAiB,CAAC;AAEzC,MAAM,uBAAuB,GAAiB,IAAI,CAAC;AACnD,MAAM,uBAAuB,GAAiB,KAAK,CAAC;AAKpD,IAAI,SAAwD,CAAC;AAC7D,IAAI,aAAuC,CAAC;AAC5C,IAAI,eAA6B,CAAC;A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b,IAAI,EACJ,cAAc,CACf,CAAC;IACF,IAAI,CAAC,OAAO,EAAE;QACZ,SAAS,GAAG,SAAS,CAAC;QACtB,aAAa,GAAG,SAAS,CAAC;KAC3B;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AArBD,oBAqBC;AAED,SAAgB,QAAQ;IACtB,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;KACjD;IACD,OAAO,SAAS,CAAC,KAAK,CAAC;AACzB,CAAC;AALD,4BAKC;AAED,SAAgB,UAAU,CAAC,OAAgB;IACzC,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;KACjD;IACD,SAAS,CAAC,OAAO,GAAG,OAAO,CAAC;AAC9B,CAAC;AALD,gCAKC;AAED,SAAgB,SAAS;IACvB,OAAO,CAAC,CAAC,SAAS,CAAC;AACrB,CAAC;AAFD,8BAEC;AAEY,QAAA,SAAS,GAAG,EAAC,YAAY,EAAC,CAAC"}
|
package/out/src/v8-types.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export interface ProfileNode {
|
|
|
30
30
|
}
|
|
31
31
|
export interface TimeProfileNode extends ProfileNode {
|
|
32
32
|
hitCount: number;
|
|
33
|
+
contexts?: object[];
|
|
33
34
|
}
|
|
34
35
|
export interface AllocationProfileNode extends ProfileNode {
|
|
35
36
|
allocations: Allocation[];
|
|
@@ -38,45 +39,6 @@ export interface Allocation {
|
|
|
38
39
|
sizeBytes: number;
|
|
39
40
|
count: number;
|
|
40
41
|
}
|
|
41
|
-
export interface InitialCpuProfile {
|
|
42
|
-
/** Time in nanoseconds at which profile was stopped. */
|
|
43
|
-
endTime: number;
|
|
44
|
-
samples: CpuProfileSample[];
|
|
45
|
-
/** Time in nanoseconds at which profile was started. */
|
|
46
|
-
startTime: number;
|
|
47
|
-
}
|
|
48
|
-
export interface CpuProfile {
|
|
49
|
-
/** Time in nanoseconds at which profile was stopped. */
|
|
50
|
-
endTime: number;
|
|
51
|
-
topDownRoot: CpuProfileNode;
|
|
52
|
-
/** Time in nanoseconds at which profile was started. */
|
|
53
|
-
startTime: number;
|
|
54
|
-
}
|
|
55
42
|
export interface LabelSet {
|
|
56
43
|
[key: string]: string | number;
|
|
57
44
|
}
|
|
58
|
-
export interface LabelsCpu {
|
|
59
|
-
labels: LabelSet;
|
|
60
|
-
cpuTime: number;
|
|
61
|
-
}
|
|
62
|
-
export interface CpuProfileNode extends ProfileNode {
|
|
63
|
-
hitCount: number;
|
|
64
|
-
cpuTime: number;
|
|
65
|
-
labelSets: LabelsCpu[];
|
|
66
|
-
}
|
|
67
|
-
export interface CpuProfileSample {
|
|
68
|
-
labels: LabelSet;
|
|
69
|
-
locations: CodeEvent[];
|
|
70
|
-
cpuTime: number;
|
|
71
|
-
}
|
|
72
|
-
export interface CodeEvent {
|
|
73
|
-
address: number;
|
|
74
|
-
previousAddress?: number;
|
|
75
|
-
size: number;
|
|
76
|
-
comment?: string;
|
|
77
|
-
functionName?: string;
|
|
78
|
-
scriptName?: string;
|
|
79
|
-
scriptId: number;
|
|
80
|
-
line: number;
|
|
81
|
-
column: number;
|
|
82
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/pprof",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "pprof support for Node.js",
|
|
5
5
|
"repository": "datadog/pprof-nodejs",
|
|
6
6
|
"main": "out/src/index.js",
|
|
@@ -8,16 +8,15 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"install": "exit 0",
|
|
10
10
|
"rebuild": "node-gyp rebuild --jobs=max",
|
|
11
|
-
"test:js": "nyc mocha out/test/test-*.js",
|
|
11
|
+
"test:js": "nyc mocha -r source-map-support/register out/test/test-*.js",
|
|
12
12
|
"test:cpp": "node scripts/cctest.js",
|
|
13
|
+
"test:wall": "nyc mocha -r source-map-support/register out/test/test-time-profiler.js",
|
|
13
14
|
"test": "npm run test:js && npm run test:cpp",
|
|
14
15
|
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json",
|
|
15
16
|
"compile": "tsc -p .",
|
|
16
17
|
"fix": "gts fix",
|
|
17
18
|
"lint": "jsgl --local . && gts check && clang-format --style file -n -Werror --glob='bindings/**/*.{h,hh,cpp,cc}'",
|
|
18
19
|
"format": "clang-format --style file -i --glob='bindings/**/*.{h,hh,cpp,cc}'",
|
|
19
|
-
"prebuild": "node scripts/prebuild.js",
|
|
20
|
-
"prebuilds": "node scripts/prebuilds.js",
|
|
21
20
|
"prepare": "npm run compile && npm run rebuild",
|
|
22
21
|
"pretest": "npm run compile"
|
|
23
22
|
},
|
|
@@ -27,48 +26,33 @@
|
|
|
27
26
|
"license": "Apache-2.0",
|
|
28
27
|
"dependencies": {
|
|
29
28
|
"delay": "^5.0.0",
|
|
30
|
-
"node-gyp-build": "
|
|
29
|
+
"node-gyp-build": "<4.0",
|
|
31
30
|
"p-limit": "^3.1.0",
|
|
32
|
-
"pify": "^5.0.0",
|
|
33
31
|
"pprof-format": "^2.0.7",
|
|
34
|
-
"source-map": "^0.7.
|
|
35
|
-
"split": "^1.0.1"
|
|
32
|
+
"source-map": "^0.7.4"
|
|
36
33
|
},
|
|
37
34
|
"devDependencies": {
|
|
38
|
-
"@types/mocha": "^
|
|
39
|
-
"@types/node": "
|
|
40
|
-
"@types/p-limit": "^2.0.0",
|
|
41
|
-
"@types/pify": "^5.0.0",
|
|
42
|
-
"@types/pretty-ms": "^5.0.1",
|
|
43
|
-
"@types/request": "^2.47.1",
|
|
35
|
+
"@types/mocha": "^10.0.1",
|
|
36
|
+
"@types/node": ">=12",
|
|
44
37
|
"@types/sinon": "^10.0.15",
|
|
45
38
|
"@types/tmp": "^0.2.3",
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
47
|
-
"axios": "^0.27.2",
|
|
48
|
-
"checksum": "^1.0.0",
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "^5.60.1",
|
|
49
40
|
"clang-format": "^1.8.0",
|
|
50
|
-
"codecov": "^3.
|
|
41
|
+
"codecov": "^3.8.2",
|
|
51
42
|
"deep-copy": "^1.4.2",
|
|
52
43
|
"eslint-config-standard": "^17.1.0",
|
|
53
|
-
"eslint-plugin-import": "^2.
|
|
54
|
-
"eslint-plugin-n": "^
|
|
44
|
+
"eslint-plugin-import": "^2.26.0",
|
|
45
|
+
"eslint-plugin-n": "^16.0.1",
|
|
55
46
|
"eslint-plugin-promise": "^6.1.1",
|
|
56
|
-
"
|
|
57
|
-
"gts": "^3.0.0",
|
|
47
|
+
"gts": "^4.0.1",
|
|
58
48
|
"js-green-licenses": "^4.0.0",
|
|
59
|
-
"
|
|
60
|
-
"mocha": "^9.2.2",
|
|
49
|
+
"mocha": "^10.2.0",
|
|
61
50
|
"nan": "^2.17.0",
|
|
62
|
-
"nyc": "^15.
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"semver": "^7.5.1",
|
|
66
|
-
"sinon": "^14.0.2",
|
|
67
|
-
"source-map-support": "^0.5.12",
|
|
68
|
-
"tar": "^6.1.15",
|
|
51
|
+
"nyc": "^15.1.0",
|
|
52
|
+
"sinon": "^15.2.0",
|
|
53
|
+
"source-map-support": "^0.5.21",
|
|
69
54
|
"tmp": "0.2.1",
|
|
70
|
-
"
|
|
71
|
-
"typescript": "^4.9.5"
|
|
55
|
+
"typescript": "<5.1"
|
|
72
56
|
},
|
|
73
57
|
"files": [
|
|
74
58
|
"out/src",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const CpuProfiler: any;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CpuProfiler = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Copyright 2018 Google Inc. All Rights Reserved.
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
const path_1 = require("path");
|
|
20
|
-
const findBinding = require('node-gyp-build');
|
|
21
|
-
const profiler = findBinding((0, path_1.join)(__dirname, '..', '..'));
|
|
22
|
-
exports.CpuProfiler = profiler.CpuProfiler;
|
|
23
|
-
//# sourceMappingURL=cpu-profiler-bindings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cpu-profiler-bindings.js","sourceRoot":"","sources":["../../ts/src/cpu-profiler-bindings.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,+BAA0B;AAE1B,MAAM,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC9C,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAE7C,QAAA,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2017 Google Inc. All Rights Reserved.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { CpuProfiler as NativeCpuProfiler } from './cpu-profiler-bindings';
|
|
17
|
-
export default class CpuProfiler extends NativeCpuProfiler {
|
|
18
|
-
profile(): import("pprof-format").Profile | undefined;
|
|
19
|
-
}
|
package/out/src/cpu-profiler.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright 2017 Google Inc. All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
const profile_serializer_1 = require("./profile-serializer");
|
|
19
|
-
const cpu_profiler_bindings_1 = require("./cpu-profiler-bindings");
|
|
20
|
-
function isNodeEqual(a, b) {
|
|
21
|
-
if (a.name !== b.name)
|
|
22
|
-
return false;
|
|
23
|
-
if (a.scriptName !== b.scriptName)
|
|
24
|
-
return false;
|
|
25
|
-
if (a.scriptId !== b.scriptId)
|
|
26
|
-
return false;
|
|
27
|
-
if (a.lineNumber !== b.lineNumber)
|
|
28
|
-
return false;
|
|
29
|
-
if (a.columnNumber !== b.columnNumber)
|
|
30
|
-
return false;
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
function makeNode(location) {
|
|
34
|
-
return {
|
|
35
|
-
name: location.comment || location.functionName,
|
|
36
|
-
scriptName: location.scriptName || '',
|
|
37
|
-
scriptId: location.scriptId,
|
|
38
|
-
lineNumber: location.line,
|
|
39
|
-
columnNumber: location.column,
|
|
40
|
-
hitCount: 0,
|
|
41
|
-
cpuTime: 0,
|
|
42
|
-
labelSets: [],
|
|
43
|
-
children: [],
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
class CpuProfiler extends cpu_profiler_bindings_1.CpuProfiler {
|
|
47
|
-
profile() {
|
|
48
|
-
if (this.frequency === 0)
|
|
49
|
-
return;
|
|
50
|
-
const profile = super.profile();
|
|
51
|
-
const timeProfile = {
|
|
52
|
-
startTime: profile.startTime,
|
|
53
|
-
endTime: profile.endTime,
|
|
54
|
-
topDownRoot: {
|
|
55
|
-
name: '(root)',
|
|
56
|
-
scriptName: '',
|
|
57
|
-
scriptId: 0,
|
|
58
|
-
lineNumber: 0,
|
|
59
|
-
columnNumber: 0,
|
|
60
|
-
hitCount: 0,
|
|
61
|
-
cpuTime: 0,
|
|
62
|
-
labelSets: [],
|
|
63
|
-
children: [],
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
let targetNode = timeProfile.topDownRoot;
|
|
67
|
-
for (const sample of profile.samples) {
|
|
68
|
-
if (!sample)
|
|
69
|
-
continue;
|
|
70
|
-
locations: for (const location of sample.locations) {
|
|
71
|
-
const node = makeNode(location);
|
|
72
|
-
for (const found of targetNode.children) {
|
|
73
|
-
const foundNode = found;
|
|
74
|
-
if (isNodeEqual(node, foundNode)) {
|
|
75
|
-
targetNode = foundNode;
|
|
76
|
-
continue locations;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
targetNode.children.push(node);
|
|
80
|
-
targetNode = node;
|
|
81
|
-
}
|
|
82
|
-
if (sample.labels && Object.keys(sample.labels).length > 0) {
|
|
83
|
-
targetNode.labelSets.push({
|
|
84
|
-
labels: sample.labels,
|
|
85
|
-
cpuTime: sample.cpuTime,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
targetNode.cpuTime += sample.cpuTime;
|
|
90
|
-
targetNode.hitCount++;
|
|
91
|
-
}
|
|
92
|
-
targetNode = timeProfile.topDownRoot;
|
|
93
|
-
}
|
|
94
|
-
const intervalMicros = 1000000 / this.frequency;
|
|
95
|
-
return (0, profile_serializer_1.serializeCpuProfile)(timeProfile, intervalMicros);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
exports.default = CpuProfiler;
|
|
99
|
-
//# sourceMappingURL=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C;gBACrC,UAAU,CAAC,QAAQ,EAAE,CAAC;aACvB;YAED,UAAU,GAAG,WAAW,CAAC,WAAW,CAAC;SACtC;QAED,MAAM,cAAc,GAAG,OAAO,GAAI,IAAI,CAAC,SAAoB,CAAC;QAC5D,OAAO,IAAA,wCAAmB,EAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IAC1D,CAAC;CACF;AAzDD,8BAyDC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const path = require('path')
|
|
4
|
-
const fs = require('fs')
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Given a package name and a module to start from, find a package's
|
|
8
|
-
* package.json file, parses it, and returns the result.
|
|
9
|
-
*
|
|
10
|
-
* Equivalent to require(`${name}/package.json`) prior to Node 12.
|
|
11
|
-
*
|
|
12
|
-
* @typedef { import('module').Module } Module
|
|
13
|
-
* @param {string} name
|
|
14
|
-
* @param {Module} module
|
|
15
|
-
* @return {Object} The parsed package.json
|
|
16
|
-
*/
|
|
17
|
-
function requirePackageJson (name, module) {
|
|
18
|
-
if (path.isAbsolute(name)) {
|
|
19
|
-
const candidate = path.join(name, 'package.json')
|
|
20
|
-
return JSON.parse(fs.readFileSync(candidate, 'utf8'))
|
|
21
|
-
}
|
|
22
|
-
for (const modulePath of module.paths) {
|
|
23
|
-
const candidate = path.join(modulePath, name, 'package.json')
|
|
24
|
-
try {
|
|
25
|
-
return JSON.parse(fs.readFileSync(candidate, 'utf8'))
|
|
26
|
-
} catch (e) {
|
|
27
|
-
continue
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
throw new Error(`could not find ${name}/package.json`)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
module.exports = requirePackageJson
|