1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-14 23:12:28 +02:00

Report block count in benchmark()

The block count can be used for testing against regression after
code changes.
This commit is contained in:
Raymond Hill 2019-04-12 10:19:38 -04:00
parent 563f6fddde
commit d2cb0f17ea
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -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';