shaka-packager/tools/page_cycler/common/report.html

184 lines
4.9 KiB
HTML
Raw Normal View History

<html>
<head>
<style>
.discarded {
color: #C0C0C0;
}
</style>
<h2>Summary</h2>
<dl>
<script src="head.js"></script>
<script>
var __results = true;
var cycles = 0;
var s = document.location.search.substring(1);
var params = s.split('&');
var iterations, pages, totalTime, fudgeTime;
for (var i = 0; i < params.length; ++i) {
var f = params[i].split('=');
switch (f[0]) {
case 'n':
iterations = (f[1] - 0);
break;
case 'i':
cycle = (f[1] - 0);
break;
case 'td':
totalTime = (f[1] - 0);
break;
case 'tf':
fudgeTime = (f[1] - 0);
break;
}
}
var pages = cycle / iterations;
document.write("<table border=1>");
document.write("<tr><td>iterations</td><td>" + iterations + "</td></tr>");
document.write("<tr><td>pages</td><td>" + pages + "</td></tr>");
document.write("<tr><td>milliseconds</td><td>" + totalTime + "</td></tr>");
document.write("<tr><td>mean per set</td><td>" + (totalTime / iterations).toFixed(2) + "</td></tr>");
document.write("<tr><td>mean per page</td><td>" + (totalTime / iterations / pages).toFixed(2) + "</td></tr>");
document.write("<tr><td>timer lag</td><td>" + (fudgeTime).toFixed(2) + "</td></tr>");
document.write("<tr><td>timer lag per page</td><td>" + (fudgeTime / iterations / pages).toFixed(2) + "</td></tr>");
document.write("</table>");
// 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);
r.errp = r.stdd / Math.sqrt((ary.length - 1) / 2) / r.mean * 100;
return r;
}
function appendTableCol(tr, text, linkify) {
var doc = tr.ownerDocument;
var td = doc.createElement("TD");
if (linkify) {
var anchor = doc.createElement("A");
if (text.indexOf('http://localhost:') == 0 ||
text.indexOf('file://') == 0) {
// URLs for page cycler HTTP and file tests.
anchor.href = text + "/index.html?skip=true";
} else {
// For Web Page Replay, URLs are same as recorded pages.
anchor.href = text;
}
anchor.appendChild(doc.createTextNode(text));
td.appendChild(anchor);
}
else
td.appendChild(doc.createTextNode(text));
tr.appendChild(td);
return td;
}
function getTimeVals() {
var rawData = __get_timings().split(",");
var timeVals = [];
for (var i = 0; i < iterations; ++i) {
for (var j = 0; j < pages; ++j) {
if (!timeVals[j])
timeVals[j] = [];
timeVals[j].push(parseInt(rawData[j + i*pages]));
}
}
return timeVals;
}
function showReport() {
var tbody = document.getElementById("tbody");
var colsums = [0,0,0,0,0];
var timeVals = getTimeVals();
for (var i = 0; i < timeVals.length; ++i) {
var tr = document.createElement("TR");
appendTableCol(tr, __pages()[i], true);
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));
appendTableCol(tr, r.errp.toFixed(2));
//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");
}
colsums[0] = colsums[0] + r.min;
colsums[1] = colsums[1] + r.max;
colsums[2] = colsums[2] + r.mean;
colsums[3] = colsums[3] + r.stdd;
colsums[4] = colsums[4] + r.errp;
tbody.appendChild(tr);
}
var tr = document.createElement("TR");
appendTableCol(tr, "totals:");
for (var k = 0; k < colsums.length; ++k)
appendTableCol(tr, colsums[k].toFixed(2));
tbody.appendChild(tr);
}
window.onload = showReport;
</script>
</dl>
</head>
<body>
<h2>Complete Statistics</h2>
<table border="1">
<thead>
<tr>
<th>Site</th>
<th>Min</th>
<th>Max</th>
<th>Mean</th>
<th>Std.d</th>
<th>Err %</th>
<th colspan="10">Runs</th>
</tr>
</thead>
<tbody id="tbody"></tbody>
</table>
</body>
</html>