Add ability to dump internal details of cosmetic filtering engine

Related commit:
- 4d482f9133
This commit is contained in:
Raymond Hill 2021-12-13 08:30:12 -05:00
parent c198b9a748
commit ba22735fcc
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
4 changed files with 50 additions and 6 deletions

View File

@ -22,8 +22,9 @@
<div class="body">
<p>
<button id="console-clear" class="iconifiable" type="button"><span class="fa-icon">trash-o</span></button>
<button id="snfe-dump" type="button">Dump SNFE</button>
<button id="snfe-benchmark" type="button" disabled>Benchmark SNFE</button>
<button id="snfe-dump" type="button">SNFE: Dump</button>
<button id="snfe-benchmark" type="button" disabled>SNFE: Benchmark</button>
<button id="cfe-dump" type="button">CFE: Dump</button>
</div>
<div id="console" class="codeMirrorContainer"></div>

View File

@ -1126,6 +1126,34 @@ FilterContainer.prototype.getFilterCount = function() {
/******************************************************************************/
FilterContainer.prototype.dump = function() {
return [
'Cosmetic Filtering Engine internals:',
`specific counts: ${this.specificFilters.size}`,
'generic counts:',
` lowly.id.simple: ${this.lowlyGeneric.id.simple.size}`,
` lowly.class.simple: ${this.lowlyGeneric.cl.simple.size}`,
` lowly.id.complex: ${this.lowlyGeneric.id.complex.size}`,
` lowly.class.complex: ${this.lowlyGeneric.cl.complex.size}`,
` highly.simple: ${this.highlyGeneric.simple.dict.size}`,
` highly.complex: ${this.highlyGeneric.complex.dict.size}`,
`lowly.id.simple: ${this.lowlyGeneric.id.simple.size}`,
...Array.from(this.lowlyGeneric.id.simple).map(a => ` ###${a}`),
`lowly.id.complex: ${this.lowlyGeneric.id.complex.size}`,
...Array.from(this.lowlyGeneric.id.complex.values()).map(a => ` ###${a}`),
`lowly.class.simple: ${this.lowlyGeneric.cl.simple.size}`,
...Array.from(this.lowlyGeneric.cl.simple).map(a => ` ##.${a}`),
`lowly.class.complex: ${this.lowlyGeneric.cl.complex.size}`,
...Array.from(this.lowlyGeneric.cl.complex.values()).map(a => ` ##.${a}`),
`highly.simple: ${this.highlyGeneric.simple.dict.size}`,
...Array.from(this.highlyGeneric.simple.dict).map(a => ` ##${a}`),
`highly.complex: ${this.lowlyGeneric.id.simple.size}`,
...Array.from(this.highlyGeneric.complex.dict).map(a => ` ##${a}`),
].join('\n');
};
/******************************************************************************/
const cosmeticFilteringEngine = new FilterContainer();
export default cosmeticFilteringEngine;

View File

@ -54,7 +54,7 @@ uDom.nodeFromId('snfe-dump').addEventListener('click', ev => {
const button = ev.target;
button.setAttribute('disabled', '');
vAPI.messaging.send('dashboard', {
what: 'sfneDump',
what: 'snfeDump',
}).then(result => {
log(result);
button.removeAttribute('disabled');
@ -70,7 +70,7 @@ vAPI.messaging.send('dashboard', {
const button = ev.target;
button.setAttribute('disabled', '');
vAPI.messaging.send('dashboard', {
what: 'sfneBenchmark',
what: 'snfeBenchmark',
}).then(result => {
log(result);
button.removeAttribute('disabled');
@ -78,4 +78,15 @@ vAPI.messaging.send('dashboard', {
});
});
uDom.nodeFromId('cfe-dump').addEventListener('click', ev => {
const button = ev.target;
button.setAttribute('disabled', '');
vAPI.messaging.send('dashboard', {
what: 'cfeDump',
}).then(result => {
log(result);
button.removeAttribute('disabled');
});
});
/******************************************************************************/

View File

@ -137,7 +137,7 @@ const onMessage = function(request, sender, callback) {
});
return;
case 'sfneBenchmark':
case 'snfeBenchmark':
µb.benchmarkStaticNetFiltering({ redirectEngine }).then(result => {
callback(result);
});
@ -239,10 +239,14 @@ const onMessage = function(request, sender, callback) {
}
break;
case 'sfneDump':
case 'snfeDump':
response = staticNetFilteringEngine.dump();
break;
case 'cfeDump':
response = cosmeticFilteringEngine.dump();
break;
default:
return vAPI.messaging.UNHANDLED;
}