@@ -1410,6 +1410,45 @@ FilterContainer.prototype.getFilterCount = function() {
1410
1410
1411
1411
/******************************************************************************/
1412
1412
1413
+ FilterContainer . prototype . benchmark = function ( ) {
1414
+ µb . loadBenchmarkDataset ( ) . then ( requests => {
1415
+ if ( Array . isArray ( requests ) === false || requests . length === 0 ) {
1416
+ console . info ( 'No requests found to benchmark' ) ;
1417
+ return ;
1418
+ }
1419
+ console . info ( `Benchmarking cosmeticFilteringEngine.matchString()...` ) ;
1420
+ const details = {
1421
+ tabId : undefined ,
1422
+ frameId : undefined ,
1423
+ hostname : '' ,
1424
+ domain : '' ,
1425
+ entity : '' ,
1426
+ } ;
1427
+ const options = {
1428
+ noCosmeticFiltering : false ,
1429
+ noGenericCosmeticFiltering : false ,
1430
+ } ;
1431
+ let count = 0 ;
1432
+ const t0 = self . performance . now ( ) ;
1433
+ for ( let i = 0 ; i < requests . length ; i ++ ) {
1434
+ const request = requests [ i ] ;
1435
+ if ( request . cpt !== 'document' ) { continue ; }
1436
+ count += 1 ;
1437
+ details . hostname = µb . URI . hostnameFromURI ( request . url ) ;
1438
+ details . domain = µb . URI . domainFromHostname ( details . hostname ) ;
1439
+ details . entity = µb . URI . entityFromDomain ( details . domain ) ;
1440
+ void this . retrieveSpecificSelectors ( details , options ) ;
1441
+ }
1442
+ const t1 = self . performance . now ( ) ;
1443
+ const dur = t1 - t0 ;
1444
+ console . info ( `Evaluated ${ count } requests in ${ dur . toFixed ( 0 ) } ms` ) ;
1445
+ console . info ( `\tAverage: ${ ( dur / count ) . toFixed ( 3 ) } ms per request` ) ;
1446
+ } ) ;
1447
+ return 'ok' ;
1448
+ } ;
1449
+
1450
+ /******************************************************************************/
1451
+
1413
1452
return new FilterContainer ( ) ;
1414
1453
1415
1454
/******************************************************************************/
0 commit comments