@parcel/profiler 2.8.4-nightly.0 → 2.8.4-nightly.2937
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/lib/SamplingProfiler.js +4 -15
- package/lib/Trace.js +0 -12
- package/lib/Tracer.js +11 -60
- package/lib/index.js +0 -4
- package/package.json +4 -4
package/lib/SamplingProfiler.js
CHANGED
|
@@ -4,33 +4,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
function _assert() {
|
|
9
8
|
const data = _interopRequireDefault(require("assert"));
|
|
10
|
-
|
|
11
9
|
_assert = function () {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _diagnostic() {
|
|
19
15
|
const data = _interopRequireDefault(require("@parcel/diagnostic"));
|
|
20
|
-
|
|
21
16
|
_diagnostic = function () {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
-
|
|
22
|
+
// https://chromedevtools.github.io/devtools-protocol/tot/Profiler#type-Profile
|
|
23
|
+
// https://chromedevtools.github.io/devtools-protocol/tot/Profiler#type-ProfileNode
|
|
24
|
+
// https://chromedevtools.github.io/devtools-protocol/tot/Runtime#type-CallFrame
|
|
25
|
+
// https://chromedevtools.github.io/devtools-protocol/tot/Profiler#type-PositionTickInfo
|
|
30
26
|
class SamplingProfiler {
|
|
31
27
|
startProfiling() {
|
|
32
28
|
let inspector;
|
|
33
|
-
|
|
34
29
|
try {
|
|
35
30
|
inspector = require('inspector');
|
|
36
31
|
} catch (err) {
|
|
@@ -42,14 +37,12 @@ class SamplingProfiler {
|
|
|
42
37
|
}
|
|
43
38
|
});
|
|
44
39
|
}
|
|
45
|
-
|
|
46
40
|
this.session = new inspector.Session();
|
|
47
41
|
this.session.connect();
|
|
48
42
|
return Promise.all([this.sendCommand('Profiler.setSamplingInterval', {
|
|
49
43
|
interval: 100
|
|
50
44
|
}), this.sendCommand('Profiler.enable'), this.sendCommand('Profiler.start')]);
|
|
51
45
|
}
|
|
52
|
-
|
|
53
46
|
sendCommand(method, params) {
|
|
54
47
|
(0, _assert().default)(this.session != null);
|
|
55
48
|
return new Promise((resolve, reject) => {
|
|
@@ -62,19 +55,15 @@ class SamplingProfiler {
|
|
|
62
55
|
});
|
|
63
56
|
});
|
|
64
57
|
}
|
|
65
|
-
|
|
66
58
|
destroy() {
|
|
67
59
|
if (this.session != null) {
|
|
68
60
|
this.session.disconnect();
|
|
69
61
|
}
|
|
70
62
|
}
|
|
71
|
-
|
|
72
63
|
async stopProfiling() {
|
|
73
64
|
let res = await this.sendCommand('Profiler.stop');
|
|
74
65
|
this.destroy();
|
|
75
66
|
return res.profile;
|
|
76
67
|
}
|
|
77
|
-
|
|
78
68
|
}
|
|
79
|
-
|
|
80
69
|
exports.default = SamplingProfiler;
|
package/lib/Trace.js
CHANGED
|
@@ -4,28 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
function _chromeTraceEvent() {
|
|
9
8
|
const data = require("chrome-trace-event");
|
|
10
|
-
|
|
11
9
|
_chromeTraceEvent = function () {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
class Trace {
|
|
19
15
|
constructor() {
|
|
20
16
|
this.tracer = new (_chromeTraceEvent().Tracer)();
|
|
21
17
|
this.tid = 0;
|
|
22
18
|
this.eventId = 0;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
getEventId() {
|
|
26
21
|
return this.eventId++;
|
|
27
22
|
}
|
|
28
|
-
|
|
29
23
|
init(ts) {
|
|
30
24
|
this.tracer.instantEvent({
|
|
31
25
|
name: 'TracingStartedInPage',
|
|
@@ -56,12 +50,10 @@ class Trace {
|
|
|
56
50
|
}
|
|
57
51
|
});
|
|
58
52
|
}
|
|
59
|
-
|
|
60
53
|
addCPUProfile(name, profile) {
|
|
61
54
|
if (this.eventId === 0) {
|
|
62
55
|
this.init(profile.startTime);
|
|
63
56
|
}
|
|
64
|
-
|
|
65
57
|
const trace = this.tracer;
|
|
66
58
|
const tid = this.tid;
|
|
67
59
|
this.tid++;
|
|
@@ -117,15 +109,11 @@ class Trace {
|
|
|
117
109
|
}
|
|
118
110
|
});
|
|
119
111
|
}
|
|
120
|
-
|
|
121
112
|
pipe(writable) {
|
|
122
113
|
return this.tracer.pipe(writable);
|
|
123
114
|
}
|
|
124
|
-
|
|
125
115
|
flush() {
|
|
126
116
|
this.tracer.push(null);
|
|
127
117
|
}
|
|
128
|
-
|
|
129
118
|
}
|
|
130
|
-
|
|
131
119
|
exports.default = Trace;
|
package/lib/Tracer.js
CHANGED
|
@@ -4,60 +4,36 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.tracer = exports.default = exports.PluginTracer = void 0;
|
|
7
|
-
|
|
8
7
|
function _events() {
|
|
9
8
|
const data = require("@parcel/events");
|
|
10
|
-
|
|
11
9
|
_events = function () {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _perf_hooks() {
|
|
19
15
|
const data = require("perf_hooks");
|
|
20
|
-
|
|
21
16
|
_perf_hooks = function () {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
// $FlowFixMe
|
|
29
22
|
let tid;
|
|
30
|
-
|
|
31
23
|
try {
|
|
32
24
|
tid = require('worker_threads').threadId;
|
|
33
25
|
} catch {
|
|
34
26
|
tid = 0;
|
|
35
27
|
}
|
|
36
|
-
|
|
37
28
|
const performance = _perf_hooks().performance;
|
|
38
|
-
|
|
39
29
|
const pid = process.pid;
|
|
40
|
-
|
|
41
30
|
class TraceMeasurement {
|
|
42
|
-
#active
|
|
43
|
-
/*
|
|
44
|
-
|
|
45
|
-
#
|
|
46
|
-
/*
|
|
47
|
-
|
|
48
|
-
#pid
|
|
49
|
-
/* number */
|
|
50
|
-
;
|
|
51
|
-
#tid
|
|
52
|
-
/* number */
|
|
53
|
-
;
|
|
54
|
-
#start
|
|
55
|
-
/* number */
|
|
56
|
-
;
|
|
57
|
-
#data
|
|
58
|
-
/* any */
|
|
59
|
-
;
|
|
60
|
-
|
|
31
|
+
#active /* boolean */ = true;
|
|
32
|
+
#name /* string */;
|
|
33
|
+
#pid /* number */;
|
|
34
|
+
#tid /* number */;
|
|
35
|
+
#start /* number */;
|
|
36
|
+
#data /* any */;
|
|
61
37
|
constructor(tracer, name, pid, tid, data) {
|
|
62
38
|
this.#name = name;
|
|
63
39
|
this.#pid = pid;
|
|
@@ -65,7 +41,6 @@ class TraceMeasurement {
|
|
|
65
41
|
this.#start = performance.now();
|
|
66
42
|
this.#data = data;
|
|
67
43
|
}
|
|
68
|
-
|
|
69
44
|
end() {
|
|
70
45
|
if (!this.#active) return;
|
|
71
46
|
const duration = performance.now() - this.#start;
|
|
@@ -80,83 +55,63 @@ class TraceMeasurement {
|
|
|
80
55
|
});
|
|
81
56
|
this.#active = false;
|
|
82
57
|
}
|
|
83
|
-
|
|
84
58
|
}
|
|
85
|
-
|
|
86
59
|
class Tracer {
|
|
87
|
-
#traceEmitter
|
|
88
|
-
/*
|
|
89
|
-
= new (_events().ValueEmitter)();
|
|
90
|
-
#enabled
|
|
91
|
-
/* boolean */
|
|
92
|
-
= false;
|
|
93
|
-
|
|
60
|
+
#traceEmitter /* ValueEmitter<TraceEvent> */ = new (_events().ValueEmitter)();
|
|
61
|
+
#enabled /* boolean */ = false;
|
|
94
62
|
onTrace(cb) {
|
|
95
63
|
return this.#traceEmitter.addListener(cb);
|
|
96
64
|
}
|
|
97
|
-
|
|
98
65
|
async wrap(name, fn) {
|
|
99
66
|
let measurement = this.createMeasurement(name);
|
|
100
|
-
|
|
101
67
|
try {
|
|
102
68
|
await fn();
|
|
103
69
|
} finally {
|
|
104
70
|
measurement && measurement.end();
|
|
105
71
|
}
|
|
106
72
|
}
|
|
107
|
-
|
|
108
73
|
createMeasurement(name, category = 'Core', argumentName, otherArgs) {
|
|
109
|
-
if (!this.enabled) return null;
|
|
110
|
-
// allocation where not required.
|
|
74
|
+
if (!this.enabled) return null;
|
|
111
75
|
|
|
76
|
+
// We create `args` in a fairly verbose way to avoid object
|
|
77
|
+
// allocation where not required.
|
|
112
78
|
let args;
|
|
113
|
-
|
|
114
79
|
if (typeof argumentName === 'string') {
|
|
115
80
|
args = {
|
|
116
81
|
name: argumentName
|
|
117
82
|
};
|
|
118
83
|
}
|
|
119
|
-
|
|
120
84
|
if (typeof otherArgs === 'object') {
|
|
121
85
|
if (typeof args == 'undefined') {
|
|
122
86
|
args = {};
|
|
123
87
|
}
|
|
124
|
-
|
|
125
88
|
for (const [k, v] of Object.entries(otherArgs)) {
|
|
126
89
|
args[k] = v;
|
|
127
90
|
}
|
|
128
91
|
}
|
|
129
|
-
|
|
130
92
|
const data = {
|
|
131
93
|
categories: [category],
|
|
132
94
|
args
|
|
133
95
|
};
|
|
134
96
|
return new TraceMeasurement(this, name, pid, tid, data);
|
|
135
97
|
}
|
|
136
|
-
|
|
137
98
|
get enabled() {
|
|
138
99
|
return this.#enabled;
|
|
139
100
|
}
|
|
140
|
-
|
|
141
101
|
enable() {
|
|
142
102
|
this.#enabled = true;
|
|
143
103
|
}
|
|
144
|
-
|
|
145
104
|
disable() {
|
|
146
105
|
this.#enabled = false;
|
|
147
106
|
}
|
|
148
|
-
|
|
149
107
|
trace(event) {
|
|
150
108
|
if (!this.#enabled) return;
|
|
151
109
|
this.#traceEmitter.emit(event);
|
|
152
110
|
}
|
|
153
|
-
|
|
154
111
|
}
|
|
155
|
-
|
|
156
112
|
exports.default = Tracer;
|
|
157
113
|
const tracer = new Tracer();
|
|
158
114
|
exports.tracer = tracer;
|
|
159
|
-
|
|
160
115
|
class PluginTracer {
|
|
161
116
|
/** @private */
|
|
162
117
|
|
|
@@ -167,15 +122,11 @@ class PluginTracer {
|
|
|
167
122
|
this.origin = opts.origin;
|
|
168
123
|
this.category = opts.category;
|
|
169
124
|
}
|
|
170
|
-
|
|
171
125
|
get enabled() {
|
|
172
126
|
return tracer.enabled;
|
|
173
127
|
}
|
|
174
|
-
|
|
175
128
|
createMeasurement(name, category, argumentName, otherArgs) {
|
|
176
129
|
return tracer.createMeasurement(name, `${this.category}:${this.origin}${typeof category === 'string' ? `:${category}` : ''}`, argumentName, otherArgs);
|
|
177
130
|
}
|
|
178
|
-
|
|
179
131
|
}
|
|
180
|
-
|
|
181
132
|
exports.PluginTracer = PluginTracer;
|
package/lib/index.js
CHANGED
|
@@ -27,11 +27,7 @@ Object.defineProperty(exports, "tracer", {
|
|
|
27
27
|
return _Tracer.tracer;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
|
|
31
30
|
var _SamplingProfiler = _interopRequireDefault(require("./SamplingProfiler"));
|
|
32
|
-
|
|
33
31
|
var _Trace = _interopRequireDefault(require("./Trace"));
|
|
34
|
-
|
|
35
32
|
var _Tracer = require("./Tracer");
|
|
36
|
-
|
|
37
33
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/profiler",
|
|
3
|
-
"version": "2.8.4-nightly.
|
|
3
|
+
"version": "2.8.4-nightly.2937+3ad435157",
|
|
4
4
|
"description": "Blazing fast, zero configuration web application bundler",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"node": ">= 12.0.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@parcel/diagnostic": "2.
|
|
24
|
-
"@parcel/events": "2.
|
|
23
|
+
"@parcel/diagnostic": "2.0.0-nightly.1314+3ad435157",
|
|
24
|
+
"@parcel/events": "2.0.0-nightly.1314+3ad435157",
|
|
25
25
|
"chrome-trace-event": "^1.0.2"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "3ad435157d443da806c215d68ccf292b4e95ae0c"
|
|
28
28
|
}
|