mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
230 lines
6.8 KiB
HTML
230 lines
6.8 KiB
HTML
|
<!-- ***** BEGIN LICENSE BLOCK *****
|
||
|
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||
|
-
|
||
|
- The contents of this file are subject to the Mozilla Public License Version
|
||
|
- 1.1 (the "License"); you may not use this file except in compliance with
|
||
|
- the License. You may obtain a copy of the License at
|
||
|
- http://www.mozilla.org/MPL/
|
||
|
-
|
||
|
- Software distributed under the License is distributed on an "AS IS" basis,
|
||
|
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||
|
- for the specific language governing rights and limitations under the
|
||
|
- License.
|
||
|
-
|
||
|
- The Original Code is JavaScript local page load test.
|
||
|
-
|
||
|
- The Initial Developer of the Original Code is
|
||
|
- Google Inc.
|
||
|
- Portions created by the Initial Developer are Copyright (C) 1999
|
||
|
- the Initial Developer. All Rights Reserved.
|
||
|
-
|
||
|
- Contributor(s):
|
||
|
- Darin Fisher <darin@meer.net>
|
||
|
- Annie Sullivan <annie.sullivan@gmail.com>
|
||
|
-
|
||
|
- Alternatively, the contents of this file may be used under the terms of
|
||
|
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
||
|
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||
|
- in which case the provisions of the GPL or the LGPL are applicable instead
|
||
|
- of those above. If you wish to allow use of your version of this file only
|
||
|
- under the terms of either the GPL or the LGPL, and not to allow others to
|
||
|
- use your version of this file under the terms of the MPL, indicate your
|
||
|
- decision by deleting the provisions above and replace them with the notice
|
||
|
- and other provisions required by the LGPL or the GPL. If you do not delete
|
||
|
- the provisions above, a recipient may use your version of this file under
|
||
|
- the terms of any one of the MPL, the GPL or the LGPL.
|
||
|
-
|
||
|
- ***** END LICENSE BLOCK ***** -->
|
||
|
|
||
|
<html>
|
||
|
<script>
|
||
|
var win = null;
|
||
|
var pages = [
|
||
|
"bugzilla.mozilla.org/",
|
||
|
"lxr.mozilla.org/",
|
||
|
"vanilla-page/",
|
||
|
];
|
||
|
var pages_i18n = [
|
||
|
"bugzilla.mozilla.org/",
|
||
|
"lxr.mozilla.org/",
|
||
|
"vanilla-page/",
|
||
|
];
|
||
|
|
||
|
var NUM_PAGES;
|
||
|
var NUM_CYCLES;
|
||
|
|
||
|
function parseParams() {
|
||
|
var s = document.location.search.substring(1);
|
||
|
var params = s.split('&');
|
||
|
for (var i = 0; i < params.length; ++i) {
|
||
|
var fields = params[i].split('=');
|
||
|
switch (fields[0]) {
|
||
|
case 'cycles':
|
||
|
NUM_CYCLES = (fields[1] - 0);
|
||
|
break;
|
||
|
case 'pages':
|
||
|
NUM_PAGES = (fields[1] - 0);
|
||
|
break;
|
||
|
case 'i18n':
|
||
|
if (fields[1] == '1') {
|
||
|
pages = pages.concat(pages_i18n);
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if (!NUM_PAGES)
|
||
|
NUM_PAGES = pages.length;
|
||
|
if (!NUM_CYCLES)
|
||
|
NUM_CYCLES = 5;
|
||
|
}
|
||
|
parseParams();
|
||
|
|
||
|
var timeVals = new Array(NUM_PAGES); // matrix of times
|
||
|
for (var i = 0; i < timeVals.length; ++i) {
|
||
|
timeVals[i] = new Array;
|
||
|
}
|
||
|
var tstart;
|
||
|
var index = 0;
|
||
|
var cycle = 0;
|
||
|
|
||
|
// returns an object with the following properties:
|
||
|
// min : min value of array elements
|
||
|
// max : max value of array elements
|
||
|
// mean : mean value of array elements
|
||
|
// vari : variance computation
|
||
|
// stdd : standard deviation, sqrt(vari)
|
||
|
// indexOfMax : index of max element (the element that is
|
||
|
// removed from the mean computation)
|
||
|
function getArrayStats(ary) {
|
||
|
var r = {};
|
||
|
r.min = ary[0];
|
||
|
r.max = ary[0];
|
||
|
r.indexOfMax = 0;
|
||
|
var sum = 0;
|
||
|
for (var i = 0; i < ary.length; ++i) {
|
||
|
if (ary[i] < r.min) {
|
||
|
r.min = ary[i];
|
||
|
} else if (ary[i] > r.max) {
|
||
|
r.max = ary[i];
|
||
|
r.indexOfMax = i;
|
||
|
}
|
||
|
sum = sum + ary[i];
|
||
|
}
|
||
|
|
||
|
// ignore max value when computing mean and stddev
|
||
|
r.mean = (sum - r.max) / (ary.length - 1);
|
||
|
|
||
|
r.vari = 0;
|
||
|
for (var i = 0; i < ary.length; ++i) {
|
||
|
if (i == r.indexOfMax)
|
||
|
continue;
|
||
|
var d = r.mean - ary[i];
|
||
|
r.vari = r.vari + d * d;
|
||
|
}
|
||
|
|
||
|
r.vari = r.vari / (ary.length - 1);
|
||
|
r.stdd = Math.sqrt(r.vari);
|
||
|
return r;
|
||
|
}
|
||
|
|
||
|
function appendTableCol(tr, text) {
|
||
|
var doc = tr.ownerDocument;
|
||
|
var td = doc.createElement("TD");
|
||
|
td.appendChild(doc.createTextNode(text));
|
||
|
tr.appendChild(td);
|
||
|
return td;
|
||
|
}
|
||
|
|
||
|
function loadReport() {
|
||
|
win.addEventListener("load", showReport, true);
|
||
|
var baseUri = document.location.href.substr(0, document.location.href.lastIndexOf('/') + 1);
|
||
|
win.document.location = baseUri + "report.html";
|
||
|
}
|
||
|
|
||
|
function showReport() {
|
||
|
var doc = win.document;
|
||
|
var tbody = doc.getElementById("tbody");
|
||
|
var sum_mean = 0;
|
||
|
var sum_stdd = 0;
|
||
|
for (var i = 0; i < timeVals.length; ++i) {
|
||
|
var tr = doc.createElement("TR");
|
||
|
|
||
|
appendTableCol(tr, pages[i]);
|
||
|
|
||
|
var r = getArrayStats(timeVals[i]);
|
||
|
appendTableCol(tr, r.min.toFixed(2));
|
||
|
appendTableCol(tr, r.max.toFixed(2));
|
||
|
appendTableCol(tr, r.mean.toFixed(2));
|
||
|
appendTableCol(tr, r.stdd.toFixed(2));
|
||
|
sum_mean += r.mean;
|
||
|
sum_stdd += r.stdd;
|
||
|
//appendTableCol(tr, r.chi2.toFixed(2));
|
||
|
|
||
|
for (var j = 0; j < timeVals[i].length; ++j) {
|
||
|
var tv = timeVals[i][j];
|
||
|
var td = appendTableCol(tr, tv);
|
||
|
if (j == r.indexOfMax)
|
||
|
td.setAttribute("class", "discarded");
|
||
|
}
|
||
|
|
||
|
tbody.appendChild(tr);
|
||
|
}
|
||
|
dump("__start_page_load_report\n");
|
||
|
dump("mean: " + sum_mean.toFixed(2) + "\n");
|
||
|
dump("stdd: " + sum_stdd.toFixed(2) + "\n");
|
||
|
dump("__end_page_load_report\n");
|
||
|
win.close()
|
||
|
window.close()
|
||
|
}
|
||
|
|
||
|
function loadPage(i) {
|
||
|
tstart = new Date();
|
||
|
win.addEventListener("load", winLoad, true);
|
||
|
win.document.location = "base/" + pages[i] + "index.html";
|
||
|
}
|
||
|
|
||
|
function winLoad() {
|
||
|
|
||
|
var tend = new Date();
|
||
|
var href = win.document.location.href;
|
||
|
if (href == "about:blank")
|
||
|
return;
|
||
|
var tdelta = tend - tstart;
|
||
|
timeVals[index].push(tdelta);
|
||
|
var fields = href.split('/');
|
||
|
|
||
|
var text = (cycle + 1) + ', ' + (index + 1) + ', ' + fields[fields.length - 2] + ", " + tdelta;
|
||
|
|
||
|
var body = document.body;
|
||
|
while (body.firstChild)
|
||
|
body.removeChild(body.firstChild);
|
||
|
body.appendChild(document.createTextNode(text));
|
||
|
|
||
|
if (++index == NUM_PAGES) {
|
||
|
index = 0;
|
||
|
if (++cycle == NUM_CYCLES) {
|
||
|
// display summary
|
||
|
try {
|
||
|
win.removeEventListener("load", winLoad, true);
|
||
|
} catch (e) { alert("displaying summary, caught " + e); }
|
||
|
win.document.location = "about:blank";
|
||
|
window.setTimeout(loadReport, 500);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
win.removeEventListener("load", winLoad, true);
|
||
|
} catch (e) { alert("Displaying page " + index + " caught " + e); }
|
||
|
win.document.location = "about:blank";
|
||
|
window.setTimeout("loadPage(" + index + ")", 500);
|
||
|
}
|
||
|
|
||
|
function init() {
|
||
|
win = window.open("about:blank", "Page Load Test");
|
||
|
window.setTimeout("loadPage(" + index + ")", 500);
|
||
|
}
|
||
|
</script>
|
||
|
<body onload="init();"></body>
|
||
|
</html>
|