@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
|
@@ -14,9 +14,32 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
17
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
41
|
exports.monitorOutOfMemory = exports.getAllocationProfile = exports.stopSamplingHeapProfiler = exports.startSamplingHeapProfiler = void 0;
|
|
19
|
-
const path = require("path");
|
|
42
|
+
const path = __importStar(require("path"));
|
|
20
43
|
const findBinding = require('node-gyp-build');
|
|
21
44
|
const profiler = findBinding(path.join(__dirname, '..', '..'));
|
|
22
45
|
// Wrappers around native heap profiler functions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heap-profiler-bindings.js","sourceRoot":"","sources":["../../ts/src/heap-profiler-bindings.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG
|
|
1
|
+
{"version":3,"file":"heap-profiler-bindings.js","sourceRoot":"","sources":["../../ts/src/heap-profiler-bindings.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA6B;AAI7B,MAAM,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC9C,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAE/D,kDAAkD;AAElD,SAAgB,yBAAyB,CACvC,iBAAyB,EACzB,cAAsB;IAEtB,QAAQ,CAAC,YAAY,CAAC,yBAAyB,CAC7C,iBAAiB,EACjB,cAAc,CACf,CAAC;AACJ,CAAC;AARD,8DAQC;AAED,SAAgB,wBAAwB;IACtC,QAAQ,CAAC,YAAY,CAAC,wBAAwB,EAAE,CAAC;AACnD,CAAC;AAFD,4DAEC;AAED,SAAgB,oBAAoB;IAClC,OAAO,QAAQ,CAAC,YAAY,CAAC,oBAAoB,EAAE,CAAC;AACtD,CAAC;AAFD,oDAEC;AAID,SAAgB,kBAAkB,CAChC,sBAA8B,EAC9B,0BAAkC,EAClC,uBAAgC,EAChC,aAAwC,EACxC,QAA2C,EAC3C,YAAoB;IAEpB,QAAQ,CAAC,YAAY,CAAC,kBAAkB,CACtC,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,aAAa,EACb,QAAQ,EACR,YAAY,CACb,CAAC;AACJ,CAAC;AAhBD,gDAgBC"}
|
package/out/src/index.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import cpuProfiler from './cpu-profiler';
|
|
2
1
|
import * as heapProfiler from './heap-profiler';
|
|
3
2
|
import * as timeProfiler from './time-profiler';
|
|
4
|
-
export { AllocationProfileNode, TimeProfileNode, ProfileNode } from './v8-types';
|
|
3
|
+
export { AllocationProfileNode, TimeProfileNode, ProfileNode, LabelSet, } from './v8-types';
|
|
5
4
|
export { encode, encodeSync } from './profile-encoder';
|
|
6
5
|
export { SourceMapper } from './sourcemapper/sourcemapper';
|
|
7
6
|
export { setLogger } from './logger';
|
|
8
|
-
export declare const CpuProfiler: typeof cpuProfiler;
|
|
9
7
|
export declare const time: {
|
|
10
8
|
profile: typeof timeProfiler.profile;
|
|
11
9
|
start: typeof timeProfiler.start;
|
|
10
|
+
stop: typeof timeProfiler.stop;
|
|
11
|
+
setContext: typeof timeProfiler.setContext;
|
|
12
|
+
isStarted: typeof timeProfiler.isStarted;
|
|
13
|
+
getState: typeof timeProfiler.getState;
|
|
14
|
+
constants: {
|
|
15
|
+
kSampleCount: any;
|
|
16
|
+
};
|
|
12
17
|
};
|
|
13
18
|
export declare const heap: {
|
|
14
19
|
start: typeof heapProfiler.start;
|
package/out/src/index.js
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.heap = exports.time = exports.
|
|
26
|
+
exports.heap = exports.time = exports.setLogger = exports.SourceMapper = exports.encodeSync = exports.encode = void 0;
|
|
4
27
|
/**
|
|
5
28
|
* Copyright 2019 Google Inc. All Rights Reserved.
|
|
6
29
|
*
|
|
@@ -17,10 +40,9 @@ exports.heap = exports.time = exports.CpuProfiler = exports.setLogger = exports.
|
|
|
17
40
|
* limitations under the License.
|
|
18
41
|
*/
|
|
19
42
|
const fs_1 = require("fs");
|
|
20
|
-
const
|
|
21
|
-
const heapProfiler = require("./heap-profiler");
|
|
43
|
+
const heapProfiler = __importStar(require("./heap-profiler"));
|
|
22
44
|
const profile_encoder_1 = require("./profile-encoder");
|
|
23
|
-
const timeProfiler = require("./time-profiler");
|
|
45
|
+
const timeProfiler = __importStar(require("./time-profiler"));
|
|
24
46
|
var profile_encoder_2 = require("./profile-encoder");
|
|
25
47
|
Object.defineProperty(exports, "encode", { enumerable: true, get: function () { return profile_encoder_2.encode; } });
|
|
26
48
|
Object.defineProperty(exports, "encodeSync", { enumerable: true, get: function () { return profile_encoder_2.encodeSync; } });
|
|
@@ -28,10 +50,14 @@ var sourcemapper_1 = require("./sourcemapper/sourcemapper");
|
|
|
28
50
|
Object.defineProperty(exports, "SourceMapper", { enumerable: true, get: function () { return sourcemapper_1.SourceMapper; } });
|
|
29
51
|
var logger_1 = require("./logger");
|
|
30
52
|
Object.defineProperty(exports, "setLogger", { enumerable: true, get: function () { return logger_1.setLogger; } });
|
|
31
|
-
exports.CpuProfiler = cpu_profiler_1.default;
|
|
32
53
|
exports.time = {
|
|
33
54
|
profile: timeProfiler.profile,
|
|
34
55
|
start: timeProfiler.start,
|
|
56
|
+
stop: timeProfiler.stop,
|
|
57
|
+
setContext: timeProfiler.setContext,
|
|
58
|
+
isStarted: timeProfiler.isStarted,
|
|
59
|
+
getState: timeProfiler.getState,
|
|
60
|
+
constants: timeProfiler.constants,
|
|
35
61
|
};
|
|
36
62
|
exports.heap = {
|
|
37
63
|
start: heapProfiler.start,
|
|
@@ -44,11 +70,11 @@ exports.heap = {
|
|
|
44
70
|
};
|
|
45
71
|
// If loaded with --require, start profiling.
|
|
46
72
|
if (module.parent && module.parent.id === 'internal/preload') {
|
|
47
|
-
|
|
73
|
+
exports.time.start({});
|
|
48
74
|
process.on('exit', () => {
|
|
49
75
|
// The process is going to terminate imminently. All work here needs to
|
|
50
76
|
// be synchronous.
|
|
51
|
-
const profile = stop();
|
|
77
|
+
const profile = exports.time.stop();
|
|
52
78
|
const buffer = (0, profile_encoder_1.encodeSync)(profile);
|
|
53
79
|
(0, fs_1.writeFileSync)(`pprof-profile-${process.pid}.pb.gz`, buffer);
|
|
54
80
|
});
|
package/out/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,2BAAiC;AAEjC,8DAAgD;AAChD,uDAA6C;AAC7C,8DAAgD;AAQhD,qDAAqD;AAA7C,yGAAA,MAAM,OAAA;AAAE,6GAAA,UAAU,OAAA;AAC1B,4DAAyD;AAAjD,4GAAA,YAAY,OAAA;AACpB,mCAAmC;AAA3B,mGAAA,SAAS,OAAA;AAEJ,QAAA,IAAI,GAAG;IAClB,OAAO,EAAE,YAAY,CAAC,OAAO;IAC7B,KAAK,EAAE,YAAY,CAAC,KAAK;IACzB,IAAI,EAAE,YAAY,CAAC,IAAI;IACvB,UAAU,EAAE,YAAY,CAAC,UAAU;IACnC,SAAS,EAAE,YAAY,CAAC,SAAS;IACjC,QAAQ,EAAE,YAAY,CAAC,QAAQ;IAC/B,SAAS,EAAE,YAAY,CAAC,SAAS;CAClC,CAAC;AAEW,QAAA,IAAI,GAAG;IAClB,KAAK,EAAE,YAAY,CAAC,KAAK;IACzB,IAAI,EAAE,YAAY,CAAC,IAAI;IACvB,OAAO,EAAE,YAAY,CAAC,OAAO;IAC7B,cAAc,EAAE,YAAY,CAAC,cAAc;IAC3C,SAAS,EAAE,YAAY,CAAC,SAAS;IACjC,kBAAkB,EAAE,YAAY,CAAC,kBAAkB;IACnD,YAAY,EAAE,YAAY,CAAC,YAAY;CACxC,CAAC;AAEF,6CAA6C;AAC7C,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,kBAAkB,EAAE;IAC5D,YAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACtB,uEAAuE;QACvE,kBAAkB;QAClB,MAAM,OAAO,GAAG,YAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,IAAA,4BAAU,EAAC,OAAO,CAAC,CAAC;QACnC,IAAA,kBAAa,EAAC,iBAAiB,OAAO,CAAC,GAAG,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;CACJ"}
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.encodeSync = exports.encode = void 0;
|
|
19
|
-
const
|
|
19
|
+
const util_1 = require("util");
|
|
20
20
|
const zlib_1 = require("zlib");
|
|
21
|
-
const gzipPromise =
|
|
21
|
+
const gzipPromise = (0, util_1.promisify)(zlib_1.gzip);
|
|
22
22
|
async function encode(profile) {
|
|
23
23
|
return gzipPromise(profile.encode());
|
|
24
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-encoder.js","sourceRoot":"","sources":["../../ts/src/profile-encoder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH
|
|
1
|
+
{"version":3,"file":"profile-encoder.js","sourceRoot":"","sources":["../../ts/src/profile-encoder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,+BAA+B;AAC/B,+BAAoC;AAIpC,MAAM,WAAW,GAAG,IAAA,gBAAS,EAAC,WAAI,CAAC,CAAC;AAE7B,KAAK,UAAU,MAAM,CAAC,OAAgB;IAC3C,OAAO,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AACvC,CAAC;AAFD,wBAEC;AAED,SAAgB,UAAU,CAAC,OAAgB;IACzC,OAAO,IAAA,eAAQ,EAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AACpC,CAAC;AAFD,gCAEC"}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { Profile } from 'pprof-format';
|
|
17
17
|
import { SourceMapper } from './sourcemapper/sourcemapper';
|
|
18
|
-
import { AllocationProfileNode,
|
|
18
|
+
import { AllocationProfileNode, LabelSet, TimeProfile } from './v8-types';
|
|
19
19
|
/**
|
|
20
20
|
* Converts v8 time profile into into a profile proto.
|
|
21
21
|
* (https://github.com/google/pprof/blob/master/proto/profile.proto)
|
|
@@ -23,15 +23,7 @@ import { AllocationProfileNode, CpuProfile, TimeProfile } from './v8-types';
|
|
|
23
23
|
* @param prof - profile to be converted.
|
|
24
24
|
* @param intervalMicros - average time (microseconds) between samples.
|
|
25
25
|
*/
|
|
26
|
-
export declare function serializeTimeProfile(prof: TimeProfile, intervalMicros: number, sourceMapper?: SourceMapper, recomputeSamplingInterval?: boolean): Profile;
|
|
27
|
-
/**
|
|
28
|
-
* Converts cpu profile into into a profile proto.
|
|
29
|
-
* (https://github.com/google/pprof/blob/master/proto/profile.proto)
|
|
30
|
-
*
|
|
31
|
-
* @param prof - profile to be converted.
|
|
32
|
-
* @param intervalMicros - average time (microseconds) between samples.
|
|
33
|
-
*/
|
|
34
|
-
export declare function serializeCpuProfile(prof: CpuProfile, intervalMicros: number, sourceMapper?: SourceMapper): Profile;
|
|
26
|
+
export declare function serializeTimeProfile(prof: TimeProfile, intervalMicros: number, sourceMapper?: SourceMapper, recomputeSamplingInterval?: boolean, generateLabels?: (context: object) => LabelSet): Profile;
|
|
35
27
|
/**
|
|
36
28
|
* Converts v8 heap profile into into a profile proto.
|
|
37
29
|
* (https://github.com/google/pprof/blob/master/proto/profile.proto)
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.serializeHeapProfile = exports.
|
|
18
|
+
exports.serializeHeapProfile = exports.serializeTimeProfile = void 0;
|
|
19
19
|
const pprof_format_1 = require("pprof-format");
|
|
20
20
|
function isGeneratedLocation(location) {
|
|
21
21
|
return (location.column !== undefined &&
|
|
@@ -135,16 +135,6 @@ function createTimeValueType(table) {
|
|
|
135
135
|
unit: table.dedup('nanoseconds'),
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
/**
|
|
139
|
-
* @return value type for cpu samples (type:cpu, units:nanoseconds), and
|
|
140
|
-
* adds strings used in this value type to the table.
|
|
141
|
-
*/
|
|
142
|
-
function createCpuValueType(table) {
|
|
143
|
-
return new pprof_format_1.ValueType({
|
|
144
|
-
type: table.dedup('cpu'),
|
|
145
|
-
unit: table.dedup('nanoseconds'),
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
138
|
/**
|
|
149
139
|
* @return value type for object counts (type:objects, units:count), and
|
|
150
140
|
* adds strings used in this value type to the table.
|
|
@@ -176,7 +166,7 @@ function computeTotalHitCount(root) {
|
|
|
176
166
|
* @param prof - profile to be converted.
|
|
177
167
|
* @param intervalMicros - average time (microseconds) between samples.
|
|
178
168
|
*/
|
|
179
|
-
function serializeTimeProfile(prof, intervalMicros, sourceMapper, recomputeSamplingInterval = false) {
|
|
169
|
+
function serializeTimeProfile(prof, intervalMicros, sourceMapper, recomputeSamplingInterval = false, generateLabels) {
|
|
180
170
|
// If requested, recompute sampling interval from profile duration and total number of hits,
|
|
181
171
|
// since profile duration should be #hits x interval.
|
|
182
172
|
// Recomputing an average interval is more accurate, since in practice intervals between
|
|
@@ -192,10 +182,23 @@ function serializeTimeProfile(prof, intervalMicros, sourceMapper, recomputeSampl
|
|
|
192
182
|
}
|
|
193
183
|
const intervalNanos = intervalMicros * 1000;
|
|
194
184
|
const appendTimeEntryToSamples = (entry, samples) => {
|
|
195
|
-
|
|
185
|
+
let unlabelledHits = entry.node.hitCount;
|
|
186
|
+
for (const context of entry.node.contexts || []) {
|
|
187
|
+
const labels = generateLabels ? generateLabels(context) : context;
|
|
188
|
+
if (Object.keys(labels).length > 0) {
|
|
189
|
+
const sample = new pprof_format_1.Sample({
|
|
190
|
+
locationId: entry.stack,
|
|
191
|
+
value: [1, intervalNanos],
|
|
192
|
+
label: buildLabels(labels, stringTable),
|
|
193
|
+
});
|
|
194
|
+
samples.push(sample);
|
|
195
|
+
unlabelledHits--;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (unlabelledHits > 0) {
|
|
196
199
|
const sample = new pprof_format_1.Sample({
|
|
197
200
|
locationId: entry.stack,
|
|
198
|
-
value: [
|
|
201
|
+
value: [unlabelledHits, unlabelledHits * intervalNanos],
|
|
199
202
|
});
|
|
200
203
|
samples.push(sample);
|
|
201
204
|
}
|
|
@@ -230,47 +233,6 @@ function buildLabels(labelSet, stringTable) {
|
|
|
230
233
|
}
|
|
231
234
|
return labels;
|
|
232
235
|
}
|
|
233
|
-
/**
|
|
234
|
-
* Converts cpu profile into into a profile proto.
|
|
235
|
-
* (https://github.com/google/pprof/blob/master/proto/profile.proto)
|
|
236
|
-
*
|
|
237
|
-
* @param prof - profile to be converted.
|
|
238
|
-
* @param intervalMicros - average time (microseconds) between samples.
|
|
239
|
-
*/
|
|
240
|
-
function serializeCpuProfile(prof, intervalMicros, sourceMapper) {
|
|
241
|
-
const intervalNanos = intervalMicros * 1000;
|
|
242
|
-
const appendCpuEntryToSamples = (entry, samples) => {
|
|
243
|
-
for (const labelCpu of entry.node.labelSets) {
|
|
244
|
-
const sample = new pprof_format_1.Sample({
|
|
245
|
-
locationId: entry.stack,
|
|
246
|
-
value: [1, labelCpu.cpuTime],
|
|
247
|
-
label: buildLabels(labelCpu.labels, stringTable),
|
|
248
|
-
});
|
|
249
|
-
samples.push(sample);
|
|
250
|
-
}
|
|
251
|
-
if (entry.node.hitCount > 0) {
|
|
252
|
-
const sample = new pprof_format_1.Sample({
|
|
253
|
-
locationId: entry.stack,
|
|
254
|
-
value: [entry.node.hitCount, entry.node.cpuTime],
|
|
255
|
-
});
|
|
256
|
-
samples.push(sample);
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
const stringTable = new pprof_format_1.StringTable();
|
|
260
|
-
const sampleValueType = createSampleCountValueType(stringTable);
|
|
261
|
-
// const wallValueType = createTimeValueType(stringTable);
|
|
262
|
-
const cpuValueType = createCpuValueType(stringTable);
|
|
263
|
-
const profile = {
|
|
264
|
-
sampleType: [sampleValueType, cpuValueType /*, wallValueType*/],
|
|
265
|
-
timeNanos: Date.now() * 1000 * 1000,
|
|
266
|
-
durationNanos: prof.endTime - prof.startTime,
|
|
267
|
-
periodType: cpuValueType,
|
|
268
|
-
period: intervalNanos,
|
|
269
|
-
};
|
|
270
|
-
serialize(profile, prof.topDownRoot, appendCpuEntryToSamples, stringTable, undefined, sourceMapper);
|
|
271
|
-
return new pprof_format_1.Profile(profile);
|
|
272
|
-
}
|
|
273
|
-
exports.serializeCpuProfile = serializeCpuProfile;
|
|
274
236
|
/**
|
|
275
237
|
* Converts v8 heap profile into into a profile proto.
|
|
276
238
|
* (https://github.com/google/pprof/blob/master/proto/profile.proto)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-serializer.js","sourceRoot":"","sources":["../../ts/src/profile-serializer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,+CAUsB;
|
|
1
|
+
{"version":3,"file":"profile-serializer.js","sourceRoot":"","sources":["../../ts/src/profile-serializer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,+CAUsB;AAoCtB,SAAS,mBAAmB,CAC1B,QAAwB;IAExB,OAAO,CACL,QAAQ,CAAC,MAAM,KAAK,SAAS;QAC7B,QAAQ,CAAC,IAAI,KAAK,SAAS;QAC3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,wBAAwB,EACxB,WAAW,EACX,iBAAiB,EACjB,YAAY,CACb,CAAC;IAEF,OAAO,IAAI,sBAAO,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC;AA3CD,oDA2CC"}
|
|
@@ -14,19 +14,44 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
+
};
|
|
17
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
44
|
exports.SourceMapper = void 0;
|
|
19
45
|
// Originally copied from cloud-debug-nodejs's sourcemapper.ts from
|
|
20
46
|
// https://github.com/googleapis/cloud-debug-nodejs/blob/7bdc2f1f62a3b45b7b53ea79f9444c8ed50e138b/src/agent/io/sourcemapper.ts
|
|
21
47
|
// Modified to map from generated code to source code, rather than from source
|
|
22
48
|
// code to generated code.
|
|
23
|
-
const fs = require("fs");
|
|
24
|
-
const path = require("path");
|
|
25
|
-
const sourceMap = require("source-map");
|
|
49
|
+
const fs = __importStar(require("fs"));
|
|
50
|
+
const path = __importStar(require("path"));
|
|
51
|
+
const sourceMap = __importStar(require("source-map"));
|
|
26
52
|
const logger_1 = require("../logger");
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const readFile = pify(fs.readFile);
|
|
53
|
+
const p_limit_1 = __importDefault(require("p-limit"));
|
|
54
|
+
const readFile = fs.promises.readFile;
|
|
30
55
|
const CONCURRENCY = 10;
|
|
31
56
|
const MAP_EXT = '.map';
|
|
32
57
|
function error(msg) {
|
|
@@ -238,7 +263,7 @@ class SourceMapper {
|
|
|
238
263
|
}
|
|
239
264
|
exports.SourceMapper = SourceMapper;
|
|
240
265
|
async function createFromMapFiles(mapFiles, debug) {
|
|
241
|
-
const limit =
|
|
266
|
+
const limit = (0, p_limit_1.default)(CONCURRENCY);
|
|
242
267
|
const mapper = new SourceMapper(debug);
|
|
243
268
|
const promises = mapFiles.map(mapPath => limit(() => processSourceMap(mapper.infoMap, mapPath, debug)));
|
|
244
269
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sourcemapper.js","sourceRoot":"","sources":["../../../ts/src/sourcemapper/sourcemapper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG
|
|
1
|
+
{"version":3,"file":"sourcemapper.js","sourceRoot":"","sources":["../../../ts/src/sourcemapper/sourcemapper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,mEAAmE;AACnE,8HAA8H;A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3B,MAAM,KAAK,CAAC;aACb;iBAAM;gBACL,eAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,oBAAoB,KAAK,EAAE,CAAC,CAAC;aACjD;SACF;IACH,CAAC;IAED,KAAK,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,OAAe;IACxC,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,IAAI,CAC5B,OAAO,EACP,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,EACxC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAChB,IAAI,KAAK,OAAO,IAAI,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,cAAc,CACvE,EAAE;QACD,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;KAC9C;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TimeProfiler = void 0;
|
|
3
|
+
exports.constants = exports.TimeProfiler = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Copyright 2018 Google Inc. All Rights Reserved.
|
|
6
6
|
*
|
|
@@ -20,4 +20,5 @@ const path_1 = require("path");
|
|
|
20
20
|
const findBinding = require('node-gyp-build');
|
|
21
21
|
const profiler = findBinding((0, path_1.join)(__dirname, '..', '..'));
|
|
22
22
|
exports.TimeProfiler = profiler.TimeProfiler;
|
|
23
|
+
exports.constants = profiler.constants;
|
|
23
24
|
//# sourceMappingURL=time-profiler-bindings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-profiler-bindings.js","sourceRoot":"","sources":["../../ts/src/time-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,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"time-profiler-bindings.js","sourceRoot":"","sources":["../../ts/src/time-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,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC;AACrC,QAAA,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC"}
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { SourceMapper } from './sourcemapper/sourcemapper';
|
|
17
|
+
import { LabelSet } from './v8-types';
|
|
17
18
|
type Microseconds = number;
|
|
18
19
|
type Milliseconds = number;
|
|
19
20
|
export interface TimeProfilerOptions {
|
|
20
21
|
/** time in milliseconds for which to collect profile. */
|
|
21
|
-
durationMillis
|
|
22
|
+
durationMillis?: Milliseconds;
|
|
22
23
|
/** average time in microseconds between samples */
|
|
23
24
|
intervalMicros?: Microseconds;
|
|
24
25
|
sourceMapper?: SourceMapper;
|
|
25
|
-
name?: string;
|
|
26
26
|
/**
|
|
27
27
|
* This configuration option is experimental.
|
|
28
28
|
* When set to true, functions will be aggregated at the line level, rather
|
|
@@ -30,7 +30,15 @@ export interface TimeProfilerOptions {
|
|
|
30
30
|
* This defaults to false.
|
|
31
31
|
*/
|
|
32
32
|
lineNumbers?: boolean;
|
|
33
|
+
withContexts?: boolean;
|
|
33
34
|
}
|
|
34
|
-
export declare function profile(
|
|
35
|
-
export declare function start(intervalMicros
|
|
36
|
-
export
|
|
35
|
+
export declare function profile({ intervalMicros, durationMillis, sourceMapper, lineNumbers, withContexts, }: TimeProfilerOptions): Promise<import("pprof-format").Profile>;
|
|
36
|
+
export declare function start({ intervalMicros, durationMillis, sourceMapper, lineNumbers, withContexts, }: TimeProfilerOptions): void;
|
|
37
|
+
export declare function stop(restart?: boolean, generateLabels?: (context: object) => LabelSet): import("pprof-format").Profile;
|
|
38
|
+
export declare function getState(): any;
|
|
39
|
+
export declare function setContext(context?: object): void;
|
|
40
|
+
export declare function isStarted(): boolean;
|
|
41
|
+
export declare const constants: {
|
|
42
|
+
kSampleCount: any;
|
|
43
|
+
};
|
|
44
|
+
export { LabelSet };
|
package/out/src/time-profiler.js
CHANGED
|
@@ -14,59 +14,79 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
17
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.start = exports.profile = void 0;
|
|
19
|
-
const delay_1 = require("delay");
|
|
21
|
+
exports.constants = exports.isStarted = exports.setContext = exports.getState = exports.stop = exports.start = exports.profile = void 0;
|
|
22
|
+
const delay_1 = __importDefault(require("delay"));
|
|
20
23
|
const profile_serializer_1 = require("./profile-serializer");
|
|
21
24
|
const time_profiler_bindings_1 = require("./time-profiler-bindings");
|
|
25
|
+
const { kSampleCount } = time_profiler_bindings_1.constants;
|
|
22
26
|
const DEFAULT_INTERVAL_MICROS = 1000;
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
const DEFAULT_DURATION_MILLIS = 60000;
|
|
28
|
+
let gProfiler;
|
|
29
|
+
let gSourceMapper;
|
|
30
|
+
let gIntervalMicros;
|
|
31
|
+
/** Make sure to stop profiler before node shuts down, otherwise profiling
|
|
32
|
+
* signal might cause a crash if it occurs during shutdown */
|
|
33
|
+
process.once('exit', () => {
|
|
34
|
+
if (isStarted())
|
|
35
|
+
stop();
|
|
36
|
+
});
|
|
37
|
+
async function profile({ intervalMicros = DEFAULT_INTERVAL_MICROS, durationMillis = DEFAULT_DURATION_MILLIS, sourceMapper, lineNumbers = false, withContexts = false, }) {
|
|
38
|
+
start({
|
|
39
|
+
intervalMicros,
|
|
40
|
+
durationMillis,
|
|
41
|
+
sourceMapper,
|
|
42
|
+
lineNumbers,
|
|
43
|
+
withContexts,
|
|
44
|
+
});
|
|
45
|
+
await (0, delay_1.default)(durationMillis);
|
|
27
46
|
return stop();
|
|
28
47
|
}
|
|
29
48
|
exports.profile = profile;
|
|
30
|
-
|
|
31
|
-
|
|
49
|
+
// Temporarily retained for backwards compatibility with older tracer
|
|
50
|
+
function start({ intervalMicros = DEFAULT_INTERVAL_MICROS, durationMillis = DEFAULT_DURATION_MILLIS, sourceMapper, lineNumbers = false, withContexts = false, }) {
|
|
51
|
+
if (gProfiler) {
|
|
52
|
+
throw new Error('Wall profiler is already started');
|
|
53
|
+
}
|
|
54
|
+
gProfiler = new time_profiler_bindings_1.TimeProfiler(intervalMicros, durationMillis * 1000, lineNumbers, withContexts);
|
|
55
|
+
gSourceMapper = sourceMapper;
|
|
56
|
+
gIntervalMicros = intervalMicros;
|
|
57
|
+
gProfiler.start();
|
|
32
58
|
}
|
|
33
|
-
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return majorVersion < 16 ? stopOld : stop;
|
|
38
|
-
function start() {
|
|
39
|
-
const runName = ensureRunName(name);
|
|
40
|
-
profiler.start(runName, lineNumbers);
|
|
41
|
-
return runName;
|
|
59
|
+
exports.start = start;
|
|
60
|
+
function stop(restart = false, generateLabels) {
|
|
61
|
+
if (!gProfiler) {
|
|
62
|
+
throw new Error('Wall profiler is not started');
|
|
42
63
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
profiler.dispose();
|
|
49
|
-
if (restart) {
|
|
50
|
-
runName = start();
|
|
51
|
-
}
|
|
52
|
-
return (0, profile_serializer_1.serializeTimeProfile)(result, intervalMicros, sourceMapper, true);
|
|
64
|
+
const profile = gProfiler.stop(restart);
|
|
65
|
+
const serialized_profile = (0, profile_serializer_1.serializeTimeProfile)(profile, gIntervalMicros, gSourceMapper, true, generateLabels);
|
|
66
|
+
if (!restart) {
|
|
67
|
+
gProfiler = undefined;
|
|
68
|
+
gSourceMapper = undefined;
|
|
53
69
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
nextRunName = start();
|
|
61
|
-
}
|
|
62
|
-
const result = profiler.stop(runName, lineNumbers);
|
|
63
|
-
if (nextRunName) {
|
|
64
|
-
runName = nextRunName;
|
|
65
|
-
}
|
|
66
|
-
if (!restart)
|
|
67
|
-
profiler.dispose();
|
|
68
|
-
return (0, profile_serializer_1.serializeTimeProfile)(result, intervalMicros, sourceMapper, true);
|
|
70
|
+
return serialized_profile;
|
|
71
|
+
}
|
|
72
|
+
exports.stop = stop;
|
|
73
|
+
function getState() {
|
|
74
|
+
if (!gProfiler) {
|
|
75
|
+
throw new Error('Wall profiler is not started');
|
|
69
76
|
}
|
|
77
|
+
return gProfiler.state;
|
|
70
78
|
}
|
|
71
|
-
exports.
|
|
79
|
+
exports.getState = getState;
|
|
80
|
+
function setContext(context) {
|
|
81
|
+
if (!gProfiler) {
|
|
82
|
+
throw new Error('Wall profiler is not started');
|
|
83
|
+
}
|
|
84
|
+
gProfiler.context = context;
|
|
85
|
+
}
|
|
86
|
+
exports.setContext = setContext;
|
|
87
|
+
function isStarted() {
|
|
88
|
+
return !!gProfiler;
|
|
89
|
+
}
|
|
90
|
+
exports.isStarted = isStarted;
|
|
91
|
+
exports.constants = { kSampleCount };
|
|
72
92
|
//# sourceMappingURL=time-profiler.js.map
|