mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-05 18:32:30 +01:00
Add µBlock.staticNetFilteringEngine.bucketHistogram() as investigative dev tool
Additionally, lower the treshold of trieability to 4 for FilterPlainPrefix1.
This commit is contained in:
parent
5b202b9d5c
commit
a594b3f3d1
@ -1286,7 +1286,7 @@ const FilterBucket = class {
|
||||
FilterPlainPrefix1.trieableStringFromArgs(fdata)
|
||||
);
|
||||
}
|
||||
if ( this.plainPrefix1Count === 7 ) {
|
||||
if ( this.plainPrefix1Count === 3 ) {
|
||||
this.plainPrefix1Trie = FilterBucket.trieContainer.createOne();
|
||||
this._transferTrieable(
|
||||
this.plainPrefix1Id,
|
||||
@ -2867,6 +2867,23 @@ FilterContainer.prototype.benchmark = function(action) {
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
FilterContainer.prototype.bucketHistogram = function() {
|
||||
const results = [];
|
||||
for ( const [ bits, category ] of this.categories ) {
|
||||
for ( const [ th, f ] of category ) {
|
||||
if ( f instanceof FilterBucket === false ) { continue; }
|
||||
const token = µBlock.urlTokenizer.stringFromTokenHash(th);
|
||||
results.push({ bits, token, size: f.size, f });
|
||||
}
|
||||
}
|
||||
results.sort((a, b) => {
|
||||
return b.size - a.size;
|
||||
});
|
||||
console.log(results);
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
return new FilterContainer();
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -75,6 +75,19 @@
|
||||
return th;
|
||||
},
|
||||
|
||||
stringFromTokenHash: function(th) {
|
||||
if ( th === 0 ) { return ''; }
|
||||
if ( th === 63 ) { return '*'; }
|
||||
if ( th === 62 ) { return '.'; }
|
||||
const chars = '0123456789%abcdefghijklmnopqrstuvwxyz';
|
||||
let s = '';
|
||||
while ( th > 0 ) {
|
||||
s = `${chars.charAt((th & 0b111111)-1)}${s}`;
|
||||
th /= 64;
|
||||
}
|
||||
return s;
|
||||
},
|
||||
|
||||
// https://github.com/chrisaljoudi/uBlock/issues/1118
|
||||
// We limit to a maximum number of tokens.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user