Skip to content

Commit d2cb0f1

Browse files
committed
Report block count in benchmark()
The block count can be used for testing against regression after code changes.
1 parent 563f6fd commit d2cb0f1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/js/static-net-filtering.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2698,16 +2698,18 @@ FilterContainer.prototype.benchmark = function() {
26982698
}
26992699
console.info(`Benchmarking staticNetFilteringEngine.matchString()...`);
27002700
const fctxt = µb.filteringContext.duplicate();
2701+
let blockCount = 0;
27012702
const t0 = self.performance.now();
27022703
for ( const request of requests ) {
27032704
fctxt.setURL(request.url);
27042705
fctxt.setDocOriginFromURL(request.frameUrl);
27052706
fctxt.setType(request.cpt);
2706-
this.matchString(fctxt);
2707+
if ( this.matchString(fctxt) === 1 ) { blockCount += 1; }
27072708
}
27082709
const t1 = self.performance.now();
27092710
const dur = t1 - t0;
27102711
console.info(`Evaluated ${requests.length} requests in ${dur.toFixed(0)} ms`);
2712+
console.info(`\tBlocked: ${blockCount}`);
27112713
console.info(`\tAverage: ${(dur / requests.length).toFixed(3)} ms per request`);
27122714
});
27132715
return 'ok';

0 commit comments

Comments
 (0)