mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
Remove globals usage from start.js (#3847)
This commit is contained in:
parent
9761b02c79
commit
724a946c79
@ -24,7 +24,6 @@
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
import cosmeticFilteringEngine from './cosmetic-filtering.js';
|
import cosmeticFilteringEngine from './cosmetic-filtering.js';
|
||||||
import globals from './globals.js';
|
|
||||||
import io from './assets.js';
|
import io from './assets.js';
|
||||||
import scriptletFilteringEngine from './scriptlet-filtering.js';
|
import scriptletFilteringEngine from './scriptlet-filtering.js';
|
||||||
import staticNetFilteringEngine from './static-net-filtering.js';
|
import staticNetFilteringEngine from './static-net-filtering.js';
|
||||||
@ -73,11 +72,11 @@ const loadBenchmarkDataset = (( ) => {
|
|||||||
|
|
||||||
return function() {
|
return function() {
|
||||||
if ( ttlTimer !== undefined ) {
|
if ( ttlTimer !== undefined ) {
|
||||||
globals.clearTimeout(ttlTimer);
|
clearTimeout(ttlTimer);
|
||||||
ttlTimer = undefined;
|
ttlTimer = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
globals.setTimeout(( ) => {
|
setTimeout(( ) => {
|
||||||
ttlTimer = undefined;
|
ttlTimer = undefined;
|
||||||
datasetPromise = undefined;
|
datasetPromise = undefined;
|
||||||
}, 5 * 60 * 1000);
|
}, 5 * 60 * 1000);
|
||||||
@ -155,7 +154,7 @@ const loadBenchmarkDataset = (( ) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const t0 = globals.performance.now();
|
const t0 = performance.now();
|
||||||
let matchCount = 0;
|
let matchCount = 0;
|
||||||
let blockCount = 0;
|
let blockCount = 0;
|
||||||
let allowCount = 0;
|
let allowCount = 0;
|
||||||
@ -181,7 +180,7 @@ const loadBenchmarkDataset = (( ) => {
|
|||||||
staticNetFilteringEngine.redirectRequest(redirectEngine, fctxt);
|
staticNetFilteringEngine.redirectRequest(redirectEngine, fctxt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const t1 = globals.performance.now();
|
const t1 = performance.now();
|
||||||
const dur = t1 - t0;
|
const dur = t1 - t0;
|
||||||
|
|
||||||
const output = [
|
const output = [
|
||||||
@ -248,7 +247,7 @@ const loadBenchmarkDataset = (( ) => {
|
|||||||
}
|
}
|
||||||
console.info(`Benchmarking sessionFirewall.evaluateCellZY()...`);
|
console.info(`Benchmarking sessionFirewall.evaluateCellZY()...`);
|
||||||
const fctxt = new FilteringContext();
|
const fctxt = new FilteringContext();
|
||||||
const t0 = globals.performance.now();
|
const t0 = performance.now();
|
||||||
for ( const request of requests ) {
|
for ( const request of requests ) {
|
||||||
fctxt.setURL(request.url);
|
fctxt.setURL(request.url);
|
||||||
fctxt.setTabOriginFromURL(request.frameUrl);
|
fctxt.setTabOriginFromURL(request.frameUrl);
|
||||||
@ -259,7 +258,7 @@ const loadBenchmarkDataset = (( ) => {
|
|||||||
fctxt.type
|
fctxt.type
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const t1 = globals.performance.now();
|
const t1 = performance.now();
|
||||||
const dur = t1 - t0;
|
const dur = t1 - t0;
|
||||||
console.info(`Evaluated ${requests.length} requests in ${dur.toFixed(0)} ms`);
|
console.info(`Evaluated ${requests.length} requests in ${dur.toFixed(0)} ms`);
|
||||||
console.info(`\tAverage: ${(dur / requests.length).toFixed(3)} ms per request`);
|
console.info(`\tAverage: ${(dur / requests.length).toFixed(3)} ms per request`);
|
||||||
@ -286,7 +285,7 @@ const loadBenchmarkDataset = (( ) => {
|
|||||||
noGenericCosmeticFiltering: false,
|
noGenericCosmeticFiltering: false,
|
||||||
};
|
};
|
||||||
let count = 0;
|
let count = 0;
|
||||||
const t0 = globals.performance.now();
|
const t0 = performance.now();
|
||||||
for ( let i = 0; i < requests.length; i++ ) {
|
for ( let i = 0; i < requests.length; i++ ) {
|
||||||
const request = requests[i];
|
const request = requests[i];
|
||||||
if ( request.cpt !== 'main_frame' ) { continue; }
|
if ( request.cpt !== 'main_frame' ) { continue; }
|
||||||
@ -296,7 +295,7 @@ const loadBenchmarkDataset = (( ) => {
|
|||||||
details.entity = entityFromDomain(details.domain);
|
details.entity = entityFromDomain(details.domain);
|
||||||
void cosmeticFilteringEngine.retrieveSpecificSelectors(details, options);
|
void cosmeticFilteringEngine.retrieveSpecificSelectors(details, options);
|
||||||
}
|
}
|
||||||
const t1 = globals.performance.now();
|
const t1 = performance.now();
|
||||||
const dur = t1 - t0;
|
const dur = t1 - t0;
|
||||||
console.info(`Evaluated ${count} requests in ${dur.toFixed(0)} ms`);
|
console.info(`Evaluated ${count} requests in ${dur.toFixed(0)} ms`);
|
||||||
console.info(`\tAverage: ${(dur / count).toFixed(3)} ms per request`);
|
console.info(`\tAverage: ${(dur / count).toFixed(3)} ms per request`);
|
||||||
@ -319,7 +318,7 @@ const loadBenchmarkDataset = (( ) => {
|
|||||||
url: '',
|
url: '',
|
||||||
};
|
};
|
||||||
let count = 0;
|
let count = 0;
|
||||||
const t0 = globals.performance.now();
|
const t0 = performance.now();
|
||||||
for ( let i = 0; i < requests.length; i++ ) {
|
for ( let i = 0; i < requests.length; i++ ) {
|
||||||
const request = requests[i];
|
const request = requests[i];
|
||||||
if ( request.cpt !== 'main_frame' ) { continue; }
|
if ( request.cpt !== 'main_frame' ) { continue; }
|
||||||
@ -330,7 +329,7 @@ const loadBenchmarkDataset = (( ) => {
|
|||||||
details.entity = entityFromDomain(details.domain);
|
details.entity = entityFromDomain(details.domain);
|
||||||
void scriptletFilteringEngine.retrieve(details);
|
void scriptletFilteringEngine.retrieve(details);
|
||||||
}
|
}
|
||||||
const t1 = globals.performance.now();
|
const t1 = performance.now();
|
||||||
const dur = t1 - t0;
|
const dur = t1 - t0;
|
||||||
console.info(`Evaluated ${count} requests in ${dur.toFixed(0)} ms`);
|
console.info(`Evaluated ${count} requests in ${dur.toFixed(0)} ms`);
|
||||||
console.info(`\tAverage: ${(dur / count).toFixed(3)} ms per request`);
|
console.info(`\tAverage: ${(dur / count).toFixed(3)} ms per request`);
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
import cacheStorage from './cachestorage.js';
|
import cacheStorage from './cachestorage.js';
|
||||||
import contextMenu from './contextmenu.js';
|
import contextMenu from './contextmenu.js';
|
||||||
import globals from './globals.js';
|
|
||||||
import io from './assets.js';
|
import io from './assets.js';
|
||||||
import lz4Codec from './lz4.js';
|
import lz4Codec from './lz4.js';
|
||||||
import staticExtFilteringEngine from './static-ext-filtering.js';
|
import staticExtFilteringEngine from './static-ext-filtering.js';
|
||||||
@ -340,7 +339,7 @@ try {
|
|||||||
if ( vAPI.canWASM && µb.hiddenSettings.disableWebAssembly !== true ) {
|
if ( vAPI.canWASM && µb.hiddenSettings.disableWebAssembly !== true ) {
|
||||||
const wasmModuleFetcher = function(path) {
|
const wasmModuleFetcher = function(path) {
|
||||||
return fetch(`${path}.wasm`, { mode: 'same-origin' }).then(
|
return fetch(`${path}.wasm`, { mode: 'same-origin' }).then(
|
||||||
globals.WebAssembly.compileStreaming
|
WebAssembly.compileStreaming
|
||||||
).catch(reason => {
|
).catch(reason => {
|
||||||
ubolog(reason);
|
ubolog(reason);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user