|
1 #!/usr/bin/perl |
|
2 # |
|
3 # This Source Code Form is subject to the terms of the Mozilla Public |
|
4 # License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
6 use CGI::Carp qw(fatalsToBrowser); |
|
7 use CGI::Request; |
|
8 use URLTimingDataSet; |
|
9 use strict; |
|
10 |
|
11 my $request = new CGI::Request; |
|
12 my $id = $request->param('id'); #XXX need to check for valid parameter id |
|
13 |
|
14 print "Content-type: text/html\n\n"; |
|
15 |
|
16 print "<p>See Notes at the bottom of this page for some details.</p>\n"; |
|
17 print "<pre>\n"; |
|
18 my $rs = URLTimingDataSet->new($id); |
|
19 |
|
20 print "Test id: $id<br>Avg. Median : <b>", $rs->{avgmedian}, |
|
21 "</b> msec\t\tMinimum : ", $rs->{minimum}, " msec\n"; |
|
22 print "Average : ", $rs->{average}, |
|
23 " msec\t\tMaximum : ", $rs->{maximum}, " msec</pre>\n\n\n"; |
|
24 |
|
25 #XXX print more info (test id, ua, start time, user, IP, etc.) |
|
26 |
|
27 # draw the chart sorted |
|
28 # XXX enable this line to draw a chart, sorted by time. However, in order |
|
29 # to draw the chart, you will need to have installed the 'gd' drawing library, |
|
30 # and the GD and GD::Graph Perl modules. |
|
31 ###print "\n<p><img src='graph.pl?id=", $id, "' height='720' width='800'></p><br>\n"; |
|
32 |
|
33 |
|
34 print "<hr><pre>\nIDX PATH AVG MED MAX MIN TIMES ...\n"; |
|
35 |
|
36 if ($request->param('sort')) { |
|
37 print $rs->as_string_sorted(); |
|
38 } else { |
|
39 print $rs->as_string(); |
|
40 } |
|
41 print "</pre>\n"; |
|
42 printEndNotes(); |
|
43 |
|
44 exit; |
|
45 |
|
46 |
|
47 sub printEndNotes { |
|
48 print <<"EndOfNotes"; |
|
49 |
|
50 <hr> |
|
51 <p> |
|
52 <ol> |
|
53 <li>Times are in milliseconds. |
|
54 |
|
55 <li>AVG, MED, MIN and MAX are the average, median, maximum and |
|
56 minimum of the (non-NaN) test results for a given page. |
|
57 |
|
58 <li>If a page fails to fire the onload event within 30 seconds, |
|
59 the test for that page is "aborted": a different JS function kicks in, |
|
60 cleans up, and reports the time as "NaN". (The rest of the pages in |
|
61 the series should still be loaded normally after this). |
|
62 |
|
63 <li>The value for AVG reported for 'All Pages' is the average of |
|
64 the averages for all the pages loaded. |
|
65 |
|
66 <li>The value for MAX and MIN reported for 'All Pages' are the |
|
67 overall maximum and minimum for all pages loaded (keeping in mind that |
|
68 a load that never finishes is recorded as "NaN".) |
|
69 |
|
70 <li>The value for MED reported for 'All Pages' is the _average_ of |
|
71 the medians for all the pages loaded (i.e., it is not the median of |
|
72 the medians). |
|
73 |
|
74 </ol> |
|
75 |
|
76 </p> |
|
77 EndOfNotes |
|
78 } |