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