Home | History | Annotate | Download | only in common
      1 <html>
      2 <head>
      3 <style>
      4 .discarded {
      5   color: #C0C0C0;
      6 }
      7 </style>
      8 <h2>Summary</h2>
      9 <dl>
     10 <script src="head.js"></script>
     11 <script>
     12 var __results = true;
     13 var cycles = 0;
     14 var s = document.location.search.substring(1);
     15 var params = s.split('&');
     16 var iterations, pages, totalTime, fudgeTime;
     17 for (var i = 0; i < params.length; ++i) {
     18   var f = params[i].split('=');
     19   switch (f[0]) {
     20   case 'n':
     21     iterations = (f[1] - 0);
     22     break;
     23   case 'i':
     24     cycle = (f[1] - 0);
     25     break;
     26   case 'td':
     27     totalTime = (f[1] - 0);
     28     break;
     29   case 'tf':
     30     fudgeTime = (f[1] - 0);
     31     break;
     32   }
     33 }
     34 var pages = cycle / iterations;
     35 document.write("<table border=1>");
     36 document.write("<tr><td>iterations</td><td>" + iterations + "</td></tr>");
     37 document.write("<tr><td>pages</td><td>" + pages + "</td></tr>");
     38 document.write("<tr><td>milliseconds</td><td>" + totalTime + "</td></tr>");
     39 document.write("<tr><td>mean per set</td><td>" + (totalTime / iterations).toFixed(2) + "</td></tr>");
     40 document.write("<tr><td>mean per page</td><td>" + (totalTime / iterations / pages).toFixed(2) + "</td></tr>");
     41 document.write("<tr><td>timer lag</td><td>" + (fudgeTime).toFixed(2) + "</td></tr>");
     42 document.write("<tr><td>timer lag per page</td><td>" + (fudgeTime / iterations / pages).toFixed(2) + "</td></tr>");
     43 document.write("</table>");
     44 
     45   // returns an object with the following properties:
     46   //   min  : min value of array elements
     47   //   max  : max value of array elements
     48   //   mean : mean value of array elements
     49   //   vari : variance computation
     50   //   stdd : standard deviation, sqrt(vari)
     51   //   indexOfMax : index of max element (the element that is
     52   //                removed from the mean computation)
     53   function getArrayStats(ary) {
     54     var r = {};
     55     r.min = ary[0];
     56     r.max = ary[0];
     57     r.indexOfMax = 0;
     58     var sum = 0;
     59     for (var i = 0; i < ary.length; ++i) {
     60       if (ary[i] < r.min) {
     61         r.min = ary[i];
     62       } else if (ary[i] > r.max) {
     63         r.max = ary[i];
     64         r.indexOfMax = i;
     65       }
     66       sum = sum + ary[i];
     67     }
     68 
     69     // ignore max value when computing mean and stddev
     70     r.mean = (sum - r.max) / (ary.length - 1);
     71 
     72     r.vari = 0;
     73     for (var i = 0; i < ary.length; ++i) {
     74       if (i == r.indexOfMax)
     75         continue;
     76       var d = r.mean - ary[i];
     77       r.vari = r.vari + d * d;
     78     }
     79 
     80     r.vari = r.vari / (ary.length - 1);
     81     r.stdd = Math.sqrt(r.vari);
     82     r.errp = r.stdd / Math.sqrt((ary.length - 1) / 2) / r.mean * 100;
     83     return r;
     84   }
     85 
     86   function appendTableCol(tr, text, linkify) {
     87     var doc = tr.ownerDocument;
     88     var td = doc.createElement("TD");
     89     
     90     if (linkify) {
     91       var anchor = doc.createElement("A");
     92       if (text.indexOf('http://localhost:') == 0 ||
     93           text.indexOf('file://') == 0) {
     94         // URLs for page cycler HTTP and file tests.
     95         anchor.href = text + "/index.html?skip=true";
     96       } else {
     97         // For Web Page Replay, URLs are same as recorded pages.
     98         anchor.href = text;
     99       }
    100       anchor.appendChild(doc.createTextNode(text));
    101       td.appendChild(anchor);
    102     }
    103     else 
    104       td.appendChild(doc.createTextNode(text));
    105     tr.appendChild(td);
    106     return td;
    107   }
    108   
    109   function getTimeVals() {
    110     var rawData = __get_timings().split(",");
    111     var timeVals = [];
    112     for (var i = 0; i < iterations; ++i) {
    113       for (var j = 0; j < pages; ++j) {
    114         if (!timeVals[j])
    115           timeVals[j] = [];
    116         timeVals[j].push(parseInt(rawData[j + i*pages]));
    117       }
    118     }
    119     return timeVals;
    120   }
    121 
    122   function showReport() {
    123     var tbody = document.getElementById("tbody");
    124     var colsums = [0,0,0,0,0];
    125     var timeVals = getTimeVals();
    126     for (var i = 0; i < timeVals.length; ++i) {
    127       var tr = document.createElement("TR");
    128 
    129       appendTableCol(tr, __pages()[i], true);
    130 
    131       var r = getArrayStats(timeVals[i]);
    132       appendTableCol(tr, r.min.toFixed(2));
    133       appendTableCol(tr, r.max.toFixed(2));
    134       appendTableCol(tr, r.mean.toFixed(2));
    135       appendTableCol(tr, r.stdd.toFixed(2));
    136       appendTableCol(tr, r.errp.toFixed(2));
    137       //appendTableCol(tr, r.chi2.toFixed(2));
    138 
    139       for (var j = 0; j < timeVals[i].length; ++j) {
    140         var tv = timeVals[i][j];
    141         var td = appendTableCol(tr, tv);
    142         if (j == r.indexOfMax)
    143           td.setAttribute("class", "discarded");
    144       }
    145 
    146       colsums[0] = colsums[0] + r.min;
    147       colsums[1] = colsums[1] + r.max;
    148       colsums[2] = colsums[2] + r.mean;
    149       colsums[3] = colsums[3] + r.stdd;
    150       colsums[4] = colsums[4] + r.errp;
    151 
    152       tbody.appendChild(tr);
    153     }
    154 
    155     var tr = document.createElement("TR");
    156     appendTableCol(tr, "totals:");
    157     for (var k = 0; k < colsums.length; ++k)
    158       appendTableCol(tr, colsums[k].toFixed(2));
    159     tbody.appendChild(tr);
    160   }
    161   window.onload = showReport;
    162 
    163 </script>
    164 </dl>
    165 </head>
    166 <body>
    167 <h2>Complete Statistics</h2>
    168 <table border="1">
    169 <thead>
    170 <tr>
    171   <th>Site</th>
    172   <th>Min</th>
    173   <th>Max</th>
    174   <th>Mean</th>
    175   <th>Std.d</th>
    176   <th>Err %</th>
    177   <th colspan="10">Runs</th>
    178 </tr>
    179 </thead>
    180 <tbody id="tbody"></tbody>
    181 </table>
    182 </body>
    183 </html>
    184