Skip to content

Commit

Permalink
Report block count in benchmark()
Browse files Browse the repository at this point in the history
The block count can be used for testing against regression after
code changes.
  • Loading branch information
gorhill committed Apr 12, 2019
1 parent 563f6fd commit d2cb0f1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/js/static-net-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit d2cb0f1

Please sign in to comment.