diff --git a/src/benchmarks.html b/src/benchmarks.html index 6fc270ad2..6f227e919 100644 --- a/src/benchmarks.html +++ b/src/benchmarks.html @@ -7,6 +7,7 @@ + @@ -14,7 +15,9 @@

The purpose of this pane is strictly for development purpose. Please, do not open issues about it.

-

Static Network Filtering Engine: ?

+

Static Network Filtering Engine

+
+
diff --git a/src/css/benchmarks.css b/src/css/benchmarks.css new file mode 100644 index 000000000..d644bfb6c --- /dev/null +++ b/src/css/benchmarks.css @@ -0,0 +1,25 @@ +/** + uBlock Origin - a browser extension to block requests. + Copyright (C) 2018-present Raymond Hill + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see {http://www.gnu.org/licenses/}. + + Home: https://github.com/gorhill/uBlock +*/ + +#results { + font-family: mono; + font-size: 90%; + white-space: pre; + } diff --git a/src/js/benchmarks.js b/src/js/benchmarks.js index a6791f85f..8f7e0409f 100644 --- a/src/js/benchmarks.js +++ b/src/js/benchmarks.js @@ -181,6 +181,15 @@ const contexts = [ /******************************************************************************/ +const stdout = function(s) { + const parent = document.getElementById('results'); + const line = document.createElement('div'); + line.textContent = s; + parent.insertBefore(line, parent.firstElementChild); +}; + +/******************************************************************************/ + document.querySelector('#staticNetFilteringEngine button').addEventListener( 'click', ( ) => { @@ -191,11 +200,9 @@ document.querySelector('#staticNetFilteringEngine button').addEventListener( contexts, }, response => { - document.querySelector('#staticNetFilteringEngine .results') - .textContent = - `${response.duration.toFixed(2)} ms for ${contexts.length} requests, ${(response.duration / contexts.length).toFixed(3)} ms/request`; + stdout(`Static Network Filtering Engine: ${response.duration.toFixed(2)} ms for ${contexts.length} requests, ${(response.duration / contexts.length).toFixed(3)} ms/request`); } - ) + ); } );