b=450088 backing out (new reftest failed)
[wine-gecko.git] / testing / performance / talos / page_load_test / framecycler.html
blobbfaa7d2351c200b5f1105d5df83acc7bf9efd261
1 <html>
2 <script language="Javascript" type="text/javascript" src="parray.js"></script>
3 <script language="Javascript" type="text/javascript" src="quit.js"></script>
4 <script>
6 var NUM_PAGES;
7 var NUM_CYCLES;
8 var DEFAULT_TIMEOUT = 55000; //how long any given page can take to load
9 var QUIT; // whether to quit the app (with quit.js) after the tests
10 var t;
12 function parseParams() {
13 var s = document.location.search.substring(1);
14 var params = s.split('&');
15 for (var i = 0; i < params.length; ++i) {
16 var fields = params[i].split('=');
17 switch (fields[0]) {
18 case 'cycles':
19 NUM_CYCLES = (fields[1] - 0);
20 break;
21 case 'pages':
22 NUM_PAGES = (fields[1] - 0);
23 break;
24 case 'i18n':
25 if (fields[1] == '1') {
26 pages = pages.concat(pages_i18n);
28 break;
29 case 'quit':
30 QUIT = (fields[1] - 0);
31 break;
34 if (!NUM_PAGES)
35 NUM_PAGES = pages.length;
36 if (!NUM_CYCLES)
37 NUM_CYCLES = 5;
39 parseParams();
41 var timeVals = new Array(NUM_PAGES); // matrix of times
42 for (var i = 0; i < timeVals.length; ++i) {
43 timeVals[i] = new Array;
45 var tstart;
46 var index = 0;
47 var cycle = 0;
49 function compareNumbers(a, b) {
50 return a - b;
53 // returns an object with the following properties:
54 // min : min value of array elements
55 // max : max value of array elements
56 // mean : mean value of array elements
57 // vari : variance computation
58 // stdd : standard deviation, sqrt(vari)
59 // indexOfMax : index of max element (the element that is
60 // removed from the mean computation)
61 function getArrayStats(ary) {
62 var r = {};
63 r.min = ary[0];
64 r.max = ary[0];
65 r.indexOfMax = 0;
66 var sum = 0;
67 for (var i = 0; i < ary.length; ++i) {
68 if (ary[i] < r.min) {
69 r.min = ary[i];
70 } else if (ary[i] > r.max) {
71 r.max = ary[i];
72 r.indexOfMax = i;
74 sum = sum + ary[i];
77 // median
78 sorted_ary = ary.concat();
79 sorted_ary.sort(compareNumbers);
80 // remove longest run
81 sorted_ary.pop();
82 if (sorted_ary.length%2) {
83 r.median = sorted_ary[(sorted_ary.length-1)/2];
84 }else{
85 var n = Math.floor(sorted_ary.length / 2);
86 r.median = (sorted_ary[n - 1] + sorted_ary[n]) / 2;
89 // ignore max value when computing mean and stddev
90 r.mean = (sum - r.max) / (ary.length - 1);
92 r.vari = 0;
93 for (var i = 0; i < ary.length; ++i) {
94 if (i == r.indexOfMax)
95 continue;
96 var d = r.mean - ary[i];
97 r.vari = r.vari + d * d;
100 r.vari = r.vari / (ary.length - 1);
101 r.stdd = Math.sqrt(r.vari);
102 return r;
105 function appendTableCol(tr, text) {
106 var doc = tr.ownerDocument;
107 var td = doc.createElement("TD");
108 td.appendChild(doc.createTextNode(text));
109 tr.appendChild(td);
110 return td;
113 function dumpReport() {
114 var all = new Array();
115 var counter = 0;
117 for (var i = 0; i < timeVals.length; ++i) {
118 for (var j = 0; j < timeVals[i].length; ++j) {
119 all[counter] = timeVals[i][j];
120 ++counter;
124 // avg and avg median are cumulative for all the pages
125 var avgs = new Array();
126 var medians = new Array();
127 for (var i = 0; i < timeVals.length; ++i) {
128 avgs[i] = getArrayStats(timeVals[i]).mean;
129 medians[i] = getArrayStats(timeVals[i]).median;
131 var avg = getArrayStats(avgs).mean;
132 var avgmed = getArrayStats(medians).mean;
133 var rstring = "__start_page_load_report";
135 var r = getArrayStats(all);
136 dump(
137 "__start_report\n" +
138 "_x_x_mozilla_page_load,"+avgmed+","+r.max+","+r.min+"\n"+
139 "_x_x_mozilla_page_load_details,avgmedian|"+avgmed+"|average|"+avg.toFixed(2)+"|minimum|"+r.min+"|maximum|"+r.max+"|stddev|"+r.stdd.toFixed(2)
142 for (var i = 0; i < timeVals.length; ++i) {
143 r = getArrayStats(timeVals[i]);
144 fields = pages[i].split('/');
145 //rstring += "page:" + fields[5] + ":" + r.median.toFixed(2) + "\n";
146 dump(
147 '|'+
148 i+';'+
149 //pages[i]+';'+
150 fields[5]+';'+
151 r.median+';'+
152 r.mean+';'+
153 r.min+';'+
154 r.max
156 for (var j = 0; j < timeVals[i].length; ++j) {
157 dump(
158 ';'+timeVals[i][j]
161 dump("\n")
163 dump("__end_report\n\n");
164 //rstring += "__end_page_load_report";
165 //alert(rstring);
166 //dump(rstring);
169 function showReport() {
170 var doc = frames["content"].document;
171 var tbody = doc.getElementById("tbody");
172 for (var i = 0; i < timeVals.length; ++i) {
173 var tr = doc.createElement("TR");
175 appendTableCol(tr, pages[i]);
177 var r = getArrayStats(timeVals[i]);
178 appendTableCol(tr, r.min.toFixed(2));
179 appendTableCol(tr, r.max.toFixed(2));
180 appendTableCol(tr, r.mean.toFixed(2));
181 appendTableCol(tr, r.stdd.toFixed(2));
182 appendTableCol(tr, r.median.toFixed(2));
184 for (var j = 0; j < timeVals[i].length; ++j) {
185 var tv = timeVals[i][j];
186 var td = appendTableCol(tr, tv);
187 if (j == r.indexOfMax)
188 td.setAttribute("class", "discarded");
191 tbody.appendChild(tr);
195 function loadFail() {
196 dump("__FAILtimeout:" + frames["content"].document.location.href + "__FAIL");
197 if (QUIT) {
198 goQuitApplication();
200 window.close();
203 function loadPage(i) {
204 tstart = new Date();
205 t = setTimeout('loadFail()', DEFAULT_TIMEOUT);
206 frames["content"].document.location = pages[i];
209 function frameLoad() {
210 clearTimeout(t);
211 if (cycle == NUM_CYCLES) {
212 showReport();
213 dumpReport();
215 // use quit.js to quit the app if the quit param is true and
216 // we have universalxpconnect privs:
217 if (QUIT) {
218 goQuitApplication();
221 window.close();
222 return;
224 var tend = new Date();
225 var href = frames["content"].document.location.href;
226 if (href == "about:blank")
227 return;
228 var tdelta = tend - tstart;
229 timeVals[index].push(tdelta);
230 var fields = href.split('/');
232 var text = (cycle + 1) + ', ' + (index + 1) + ', ' + fields[fields.length - 2] + ", " + tdelta;
234 var doc = frames["header"].document;
235 var body = doc.body;
236 while (body.firstChild)
237 body.removeChild(body.firstChild);
238 body.appendChild(doc.createTextNode(text));
240 if (++index == NUM_PAGES) {
241 index = 0;
242 if (++cycle == NUM_CYCLES) {
243 // display summary
244 frames["content"].document.location = "report.html";
245 return;
249 window.setTimeout("loadPage(" + index + ")", 500);
252 function init() {
253 window.resizeTo(800, 800);
254 window.setTimeout("loadPage(" + index + ")", 500);
256 </script>
257 <frameset rows="40,*" onload="init()">
258 <frame name="header" src="header.html">
259 <frame name="content" src="" onload="frameLoad()">
260 </frameset>
261 </html>