mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-11 17:41:03 +01:00
Report block count in benchmark()
The block count can be used for testing against regression after code changes.
This commit is contained in:
parent
563f6fddde
commit
d2cb0f17ea
1 changed files with 3 additions and 1 deletions
|
@ -2698,16 +2698,18 @@ FilterContainer.prototype.benchmark = function() {
|
||||||
}
|
}
|
||||||
console.info(`Benchmarking staticNetFilteringEngine.matchString()...`);
|
console.info(`Benchmarking staticNetFilteringEngine.matchString()...`);
|
||||||
const fctxt = µb.filteringContext.duplicate();
|
const fctxt = µb.filteringContext.duplicate();
|
||||||
|
let blockCount = 0;
|
||||||
const t0 = self.performance.now();
|
const t0 = self.performance.now();
|
||||||
for ( const request of requests ) {
|
for ( const request of requests ) {
|
||||||
fctxt.setURL(request.url);
|
fctxt.setURL(request.url);
|
||||||
fctxt.setDocOriginFromURL(request.frameUrl);
|
fctxt.setDocOriginFromURL(request.frameUrl);
|
||||||
fctxt.setType(request.cpt);
|
fctxt.setType(request.cpt);
|
||||||
this.matchString(fctxt);
|
if ( this.matchString(fctxt) === 1 ) { blockCount += 1; }
|
||||||
}
|
}
|
||||||
const t1 = self.performance.now();
|
const t1 = self.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(`\tBlocked: ${blockCount}`);
|
||||||
console.info(`\tAverage: ${(dur / requests.length).toFixed(3)} ms per request`);
|
console.info(`\tAverage: ${(dur / requests.length).toFixed(3)} ms per request`);
|
||||||
});
|
});
|
||||||
return 'ok';
|
return 'ok';
|
||||||
|
|
Loading…
Reference in a new issue