mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-05 18:32:30 +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
@ -2698,16 +2698,18 @@ FilterContainer.prototype.benchmark = function() {
|
||||
}
|
||||
console.info(`Benchmarking staticNetFilteringEngine.matchString()...`);
|
||||
const fctxt = µb.filteringContext.duplicate();
|
||||
let blockCount = 0;
|
||||
const t0 = self.performance.now();
|
||||
for ( const request of requests ) {
|
||||
fctxt.setURL(request.url);
|
||||
fctxt.setDocOriginFromURL(request.frameUrl);
|
||||
fctxt.setType(request.cpt);
|
||||
this.matchString(fctxt);
|
||||
if ( this.matchString(fctxt) === 1 ) { blockCount += 1; }
|
||||
}
|
||||
const t1 = self.performance.now();
|
||||
const dur = t1 - t0;
|
||||
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`);
|
||||
});
|
||||
return 'ok';
|
||||
|
Loading…
Reference in New Issue
Block a user