Skip to content

Commit 1cbf542

Browse files
Release build 4.11 [ci release]
1 parent 2a7d08c commit 1cbf542

File tree

17 files changed

+877
-261
lines changed

17 files changed

+877
-261
lines changed

Sources/ContentScopeScripts/dist/contentScope.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,56 @@
521521
'elementHiding'
522522
];
523523

524+
/**
525+
* Performance monitor, holds reference to PerformanceMark instances.
526+
*/
527+
class PerformanceMonitor {
528+
constructor () {
529+
this.marks = [];
530+
}
531+
532+
/**
533+
* Create performance marker
534+
* @param {string} name
535+
* @returns {PerformanceMark}
536+
*/
537+
mark (name) {
538+
const mark = new PerformanceMark(name);
539+
this.marks.push(mark);
540+
return mark
541+
}
542+
543+
/**
544+
* Measure all performance markers
545+
*/
546+
measureAll () {
547+
this.marks.forEach((mark) => {
548+
mark.measure();
549+
});
550+
}
551+
}
552+
553+
/**
554+
* Tiny wrapper around performance.mark and performance.measure
555+
*/
556+
class PerformanceMark {
557+
/**
558+
* @param {string} name
559+
*/
560+
constructor (name) {
561+
this.name = name;
562+
performance.mark(this.name + 'Start');
563+
}
564+
565+
end () {
566+
performance.mark(this.name + 'End');
567+
}
568+
569+
measure () {
570+
performance.measure(this.name, this.name + 'Start', this.name + 'End');
571+
}
572+
}
573+
524574
function __variableDynamicImportRuntime0__(path) {
525575
switch (path) {
526576
case './features/click-to-load.js': return Promise.resolve().then(function () { return clickToLoad; });
@@ -560,6 +610,7 @@
560610
const updates = [];
561611
const features = [];
562612
const alwaysInitFeatures = new Set(['cookie']);
613+
const performanceMonitor = new PerformanceMonitor();
563614

564615
/**
565616
* @typedef {object} LoadArgs
@@ -574,6 +625,7 @@
574625
* @param {LoadArgs} args
575626
*/
576627
async function load (args) {
628+
const mark = performanceMonitor.mark('load');
577629
if (!shouldRun()) {
578630
return
579631
}
@@ -588,9 +640,11 @@
588640
});
589641
features.push(feature);
590642
}
643+
mark.end();
591644
}
592645

593646
async function init$1 (args) {
647+
const mark = performanceMonitor.mark('init');
594648
initArgs = args;
595649
if (!shouldRun()) {
596650
return
@@ -608,6 +662,10 @@
608662
const update = updates.pop();
609663
await updateFeaturesInner(update);
610664
}
665+
mark.end();
666+
if (args.debug) {
667+
performanceMonitor.measureAll();
668+
}
611669
}
612670

613671
function alwaysInitExtensionFeatures (args, featureName) {
@@ -2137,6 +2195,7 @@
21372195
constructor (featureName) {
21382196
this.name = featureName;
21392197
this._args = null;
2198+
this.monitor = new PerformanceMonitor();
21402199
}
21412200

21422201
/**
@@ -2218,18 +2277,29 @@
22182277
}
22192278

22202279
callInit (args) {
2280+
const mark = this.monitor.mark(this.name + 'CallInit');
22212281
this._args = args;
22222282
this.platform = args.platform;
22232283
this.init(args);
2284+
mark.end();
2285+
this.measure();
22242286
}
22252287

22262288
load (args) {
22272289
}
22282290

22292291
callLoad (args) {
2292+
const mark = this.monitor.mark(this.name + 'CallLoad');
22302293
this._args = args;
22312294
this.platform = args.platform;
22322295
this.load(args);
2296+
mark.end();
2297+
}
2298+
2299+
measure () {
2300+
if (this._args.debug) {
2301+
this.monitor.measureAll();
2302+
}
22332303
}
22342304

22352305
update () {

build/android/contentScope.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,56 @@
521521
'elementHiding'
522522
];
523523

524+
/**
525+
* Performance monitor, holds reference to PerformanceMark instances.
526+
*/
527+
class PerformanceMonitor {
528+
constructor () {
529+
this.marks = [];
530+
}
531+
532+
/**
533+
* Create performance marker
534+
* @param {string} name
535+
* @returns {PerformanceMark}
536+
*/
537+
mark (name) {
538+
const mark = new PerformanceMark(name);
539+
this.marks.push(mark);
540+
return mark
541+
}
542+
543+
/**
544+
* Measure all performance markers
545+
*/
546+
measureAll () {
547+
this.marks.forEach((mark) => {
548+
mark.measure();
549+
});
550+
}
551+
}
552+
553+
/**
554+
* Tiny wrapper around performance.mark and performance.measure
555+
*/
556+
class PerformanceMark {
557+
/**
558+
* @param {string} name
559+
*/
560+
constructor (name) {
561+
this.name = name;
562+
performance.mark(this.name + 'Start');
563+
}
564+
565+
end () {
566+
performance.mark(this.name + 'End');
567+
}
568+
569+
measure () {
570+
performance.measure(this.name, this.name + 'Start', this.name + 'End');
571+
}
572+
}
573+
524574
function __variableDynamicImportRuntime0__(path) {
525575
switch (path) {
526576
case './features/click-to-load.js': return Promise.resolve().then(function () { return clickToLoad; });
@@ -560,6 +610,7 @@
560610
const updates = [];
561611
const features = [];
562612
const alwaysInitFeatures = new Set(['cookie']);
613+
const performanceMonitor = new PerformanceMonitor();
563614

564615
/**
565616
* @typedef {object} LoadArgs
@@ -574,6 +625,7 @@
574625
* @param {LoadArgs} args
575626
*/
576627
async function load (args) {
628+
const mark = performanceMonitor.mark('load');
577629
if (!shouldRun()) {
578630
return
579631
}
@@ -588,9 +640,11 @@
588640
});
589641
features.push(feature);
590642
}
643+
mark.end();
591644
}
592645

593646
async function init$1 (args) {
647+
const mark = performanceMonitor.mark('init');
594648
initArgs = args;
595649
if (!shouldRun()) {
596650
return
@@ -608,6 +662,10 @@
608662
const update = updates.pop();
609663
await updateFeaturesInner(update);
610664
}
665+
mark.end();
666+
if (args.debug) {
667+
performanceMonitor.measureAll();
668+
}
611669
}
612670

613671
function alwaysInitExtensionFeatures (args, featureName) {
@@ -2137,6 +2195,7 @@
21372195
constructor (featureName) {
21382196
this.name = featureName;
21392197
this._args = null;
2198+
this.monitor = new PerformanceMonitor();
21402199
}
21412200

21422201
/**
@@ -2218,18 +2277,29 @@
22182277
}
22192278

22202279
callInit (args) {
2280+
const mark = this.monitor.mark(this.name + 'CallInit');
22212281
this._args = args;
22222282
this.platform = args.platform;
22232283
this.init(args);
2284+
mark.end();
2285+
this.measure();
22242286
}
22252287

22262288
load (args) {
22272289
}
22282290

22292291
callLoad (args) {
2292+
const mark = this.monitor.mark(this.name + 'CallLoad');
22302293
this._args = args;
22312294
this.platform = args.platform;
22322295
this.load(args);
2296+
mark.end();
2297+
}
2298+
2299+
measure () {
2300+
if (this._args.debug) {
2301+
this.monitor.measureAll();
2302+
}
22332303
}
22342304

22352305
update () {

0 commit comments

Comments
 (0)