@parcel/profiler
Advanced tools
Comparing version 2.8.4-nightly.2926 to 2.8.4-nightly.2937
@@ -30,9 +30,5 @@ "use strict"; | ||
}); | ||
var _SamplingProfiler = _interopRequireDefault(require("./SamplingProfiler")); | ||
var _Trace = _interopRequireDefault(require("./Trace")); | ||
var _Tracer = require("./Tracer"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -7,29 +7,24 @@ "use strict"; | ||
exports.default = void 0; | ||
function _assert() { | ||
const data = _interopRequireDefault(require("assert")); | ||
_assert = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _diagnostic() { | ||
const data = _interopRequireDefault(require("@parcel/diagnostic")); | ||
_diagnostic = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// https://chromedevtools.github.io/devtools-protocol/tot/Profiler#type-Profile | ||
// https://chromedevtools.github.io/devtools-protocol/tot/Profiler#type-ProfileNode | ||
// https://chromedevtools.github.io/devtools-protocol/tot/Runtime#type-CallFrame | ||
// https://chromedevtools.github.io/devtools-protocol/tot/Profiler#type-PositionTickInfo | ||
class SamplingProfiler { | ||
startProfiling() { | ||
let inspector; | ||
try { | ||
@@ -46,3 +41,2 @@ inspector = require('inspector'); | ||
} | ||
this.session = new inspector.Session(); | ||
@@ -54,3 +48,2 @@ this.session.connect(); | ||
} | ||
sendCommand(method, params) { | ||
@@ -68,3 +61,2 @@ (0, _assert().default)(this.session != null); | ||
} | ||
destroy() { | ||
@@ -75,3 +67,2 @@ if (this.session != null) { | ||
} | ||
async stopProfiling() { | ||
@@ -82,5 +73,3 @@ let res = await this.sendCommand('Profiler.stop'); | ||
} | ||
} | ||
exports.default = SamplingProfiler; |
@@ -7,13 +7,9 @@ "use strict"; | ||
exports.default = void 0; | ||
function _chromeTraceEvent() { | ||
const data = require("chrome-trace-event"); | ||
_chromeTraceEvent = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
class Trace { | ||
@@ -25,7 +21,5 @@ constructor() { | ||
} | ||
getEventId() { | ||
return this.eventId++; | ||
} | ||
init(ts) { | ||
@@ -61,3 +55,2 @@ this.tracer.instantEvent({ | ||
} | ||
addCPUProfile(name, profile) { | ||
@@ -67,3 +60,2 @@ if (this.eventId === 0) { | ||
} | ||
const trace = this.tracer; | ||
@@ -124,13 +116,9 @@ const tid = this.tid; | ||
} | ||
pipe(writable) { | ||
return this.tracer.pipe(writable); | ||
} | ||
flush() { | ||
this.tracer.push(null); | ||
} | ||
} | ||
exports.default = Trace; |
@@ -7,26 +7,18 @@ "use strict"; | ||
exports.tracer = exports.default = exports.PluginTracer = void 0; | ||
function _events() { | ||
const data = require("@parcel/events"); | ||
_events = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _perf_hooks() { | ||
const data = require("perf_hooks"); | ||
_perf_hooks = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
// $FlowFixMe | ||
let tid; | ||
try { | ||
@@ -37,27 +29,11 @@ tid = require('worker_threads').threadId; | ||
} | ||
const performance = _perf_hooks().performance; | ||
const pid = process.pid; | ||
class TraceMeasurement { | ||
#active | ||
/* boolean */ | ||
= true; | ||
#name | ||
/* string */ | ||
; | ||
#pid | ||
/* number */ | ||
; | ||
#tid | ||
/* number */ | ||
; | ||
#start | ||
/* number */ | ||
; | ||
#data | ||
/* any */ | ||
; | ||
#active /* boolean */ = true; | ||
#name /* string */; | ||
#pid /* number */; | ||
#tid /* number */; | ||
#start /* number */; | ||
#data /* any */; | ||
constructor(tracer, name, pid, tid, data) { | ||
@@ -70,3 +46,2 @@ this.#name = name; | ||
} | ||
end() { | ||
@@ -86,20 +61,11 @@ if (!this.#active) return; | ||
} | ||
} | ||
class Tracer { | ||
#traceEmitter | ||
/* ValueEmitter<TraceEvent> */ | ||
= new (_events().ValueEmitter)(); | ||
#enabled | ||
/* boolean */ | ||
= false; | ||
#traceEmitter /* ValueEmitter<TraceEvent> */ = new (_events().ValueEmitter)(); | ||
#enabled /* boolean */ = false; | ||
onTrace(cb) { | ||
return this.#traceEmitter.addListener(cb); | ||
} | ||
async wrap(name, fn) { | ||
let measurement = this.createMeasurement(name); | ||
try { | ||
@@ -111,9 +77,8 @@ await fn(); | ||
} | ||
createMeasurement(name, category = 'Core', argumentName, otherArgs) { | ||
if (!this.enabled) return null; | ||
createMeasurement(name, category = 'Core', argumentName, otherArgs) { | ||
if (!this.enabled) return null; // We create `args` in a fairly verbose way to avoid object | ||
// We create `args` in a fairly verbose way to avoid object | ||
// allocation where not required. | ||
let args; | ||
if (typeof argumentName === 'string') { | ||
@@ -124,3 +89,2 @@ args = { | ||
} | ||
if (typeof otherArgs === 'object') { | ||
@@ -130,3 +94,2 @@ if (typeof args == 'undefined') { | ||
} | ||
for (const [k, v] of Object.entries(otherArgs)) { | ||
@@ -136,3 +99,2 @@ args[k] = v; | ||
} | ||
const data = { | ||
@@ -144,15 +106,11 @@ categories: [category], | ||
} | ||
get enabled() { | ||
return this.#enabled; | ||
} | ||
enable() { | ||
this.#enabled = true; | ||
} | ||
disable() { | ||
this.#enabled = false; | ||
} | ||
trace(event) { | ||
@@ -162,9 +120,6 @@ if (!this.#enabled) return; | ||
} | ||
} | ||
exports.default = Tracer; | ||
const tracer = new Tracer(); | ||
exports.tracer = tracer; | ||
class PluginTracer { | ||
@@ -180,13 +135,9 @@ /** @private */ | ||
} | ||
get enabled() { | ||
return tracer.enabled; | ||
} | ||
createMeasurement(name, category, argumentName, otherArgs) { | ||
return tracer.createMeasurement(name, `${this.category}:${this.origin}${typeof category === 'string' ? `:${category}` : ''}`, argumentName, otherArgs); | ||
} | ||
} | ||
exports.PluginTracer = PluginTracer; |
{ | ||
"name": "@parcel/profiler", | ||
"version": "2.8.4-nightly.2926+cd4336412", | ||
"version": "2.8.4-nightly.2937+3ad435157", | ||
"description": "Blazing fast, zero configuration web application bundler", | ||
@@ -23,7 +23,7 @@ "license": "MIT", | ||
"dependencies": { | ||
"@parcel/diagnostic": "2.0.0-nightly.1303+cd4336412", | ||
"@parcel/events": "2.0.0-nightly.1303+cd4336412", | ||
"@parcel/diagnostic": "2.0.0-nightly.1314+3ad435157", | ||
"@parcel/events": "2.0.0-nightly.1314+3ad435157", | ||
"chrome-trace-event": "^1.0.2" | ||
}, | ||
"gitHead": "cd4336412242b6d6da40ef6cba8e7ac99c72b090" | ||
"gitHead": "3ad435157d443da806c215d68ccf292b4e95ae0c" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
21024
763