From d2cb0f17eadd8cccde8aa80e503dbb6a5e17bd9e Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 12 Apr 2019 10:19:38 -0400 Subject: [PATCH] Report block count in benchmark() The block count can be used for testing against regression after code changes. --- src/js/static-net-filtering.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index 261cc8621..aaa8e64b0 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -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';