2 <script language=
"Javascript" type=
"text/javascript" src=
"parray.js"></script>
3 <script language=
"Javascript" type=
"text/javascript" src=
"quit.js"></script>
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
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('=');
19 NUM_CYCLES
= (fields
[1] - 0);
22 NUM_PAGES
= (fields
[1] - 0);
25 if (fields
[1] == '1') {
26 pages
= pages
.concat(pages_i18n
);
30 QUIT
= (fields
[1] - 0);
35 NUM_PAGES
= pages
.length
;
41 var timeVals
= new Array(NUM_PAGES
); // matrix of times
42 for (var i
= 0; i
< timeVals
.length
; ++i
) {
43 timeVals
[i
] = new Array
;
49 function compareNumbers(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
) {
67 for (var i
= 0; i
< ary
.length
; ++i
) {
70 } else if (ary
[i
] > r
.max
) {
78 sorted_ary
= ary
.concat();
79 sorted_ary
.sort(compareNumbers
);
82 if (sorted_ary
.length
%2) {
83 r
.median
= sorted_ary
[(sorted_ary
.length
-1)/2];
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);
93 for (var i
= 0; i
< ary
.length
; ++i
) {
94 if (i
== r
.indexOfMax
)
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
);
105 function appendTableCol(tr
, text
) {
106 var doc
= tr
.ownerDocument
;
107 var td
= doc
.createElement("TD");
108 td
.appendChild(doc
.createTextNode(text
));
113 function dumpReport() {
114 var all
= new Array();
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
];
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
);
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";
156 for (var j
= 0; j
< timeVals
[i
].length
; ++j
) {
163 dump("__end_report\n\n");
164 //rstring += "__end_page_load_report";
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");
203 function loadPage(i
) {
205 t
= setTimeout('loadFail()', DEFAULT_TIMEOUT
);
206 frames
["content"].document
.location
= pages
[i
];
209 function frameLoad() {
211 if (cycle
== NUM_CYCLES
) {
215 // use quit.js to quit the app if the quit param is true and
216 // we have universalxpconnect privs:
224 var tend
= new Date();
225 var href
= frames
["content"].document
.location
.href
;
226 if (href
== "about:blank")
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
;
236 while (body
.firstChild
)
237 body
.removeChild(body
.firstChild
);
238 body
.appendChild(doc
.createTextNode(text
));
240 if (++index
== NUM_PAGES
) {
242 if (++cycle
== NUM_CYCLES
) {
244 frames
["content"].document
.location
= "report.html";
249 window
.setTimeout("loadPage(" + index
+ ")", 500);
253 window
.resizeTo(800, 800);
254 window
.setTimeout("loadPage(" + index
+ ")", 500);
257 <frameset rows=
"40,*" onload=
"init()">
258 <frame name=
"header" src=
"header.html">
259 <frame name=
"content" src=
"" onload=
"frameLoad()">