Bug 1146304 - Touch slider bar or tap forward button, the video got stuck 1s then...
[gecko.git] / netwerk / test / neckoTiming.pl
blob9790dce8d3101011c02edab967692654f897bf3c
1 #neckoTiming.pl
3 # This file drives the Neck Page Load Timer.
4 # Written by John A. Taylor in 2001
6 use Strict;
8 my @pageList;
9 my @fileList;
10 my @timeList;
11 my @minTimes;
12 my @maxTimes;
13 my @avgTimes;
14 my $file_name; # = "PageList_all_pages.txt";
15 my $output_file = "timing_output.html";
16 my $test_loc; # = " c:/builds/src/mozilla/dist/WIN32_O.OBJ/bin/TestPageLoad";
17 my $test_com;
18 my $num_tests=1;
19 my $num_pages=0;
21 if($#ARGV != 2){
22 usage(@ARGV);
25 $num_tests = $ARGV[0];
26 $file_name = $ARGV[1];
27 $test_loc = $ARGV[2];
29 push (@pageList, GetTestList($file_name));
31 my $i, $j, this;
32 for($i = 0; $i < $num_tests; $i++) {
33 $j=0;
34 foreach $page (@pageList) {
35 my $start, $finish, $total;
36 $test_com = $test_loc . " " . $page . " | ";
37 printf "Testing (%d/%d): $page\n",$i*$num_pages+$j+1, $num_tests * $num_pages;
38 # $start = (times)[0];
39 open (TEST, $test_com)
40 || die ("Could not find test program: $test_loc");
41 while(<TEST>) {
42 if(/>>PageLoadTime>>(\d*)>>/){
43 print "$1\n";
44 $this = $1/1000;
45 $timeList[$j][$i] = $this;
46 @avgTimes[$j] += $this;
47 if($this > @maxTimes[$j] || $i == 0) {
48 @maxTimes[$j] = $this;
50 if($this < @minTimes[$j] || $i == 0) {
51 @minTimes[$j] = $this;
55 $j++;
59 for($i = 0; $i < $j; $i++) {
60 @avgTimes[$i] /= $num_tests;
63 PrintReport();
64 print "\nHTML formated report is in: timing_output.html\nin this directory\n";
65 exit;
67 my $num_cols = $num_tests + 4;
68 sub PrintReport {
69 my $j=0;
70 open (OUT, ">$output_file");
71 print OUT "<HTML><BODY><H3>Necko Timing Test Results</H3>",
72 "<b>Number of iterations: $num_tests</b>",
73 "<TABLE border=1 cols=$num_cols><tr><td>Page Location</td><td>Avg Time</td>",
74 "<td>Max Time</td><td>Min Time</td><td colspan=$num_tests>Times ... </td>";
76 foreach $page(@pageList) {
77 #$loc=$page;
78 #$max_time = @maxTimes[$j];
79 #$min_time = @minTimes[$j];
80 #$avg_time = @avgTimes[$j];
81 #$time_1 = $timeList[$j][0];
82 #write;
83 printf OUT "<tr><td>$page</td><td>%d</td><td>@maxTimes[$j]</td><td>@minTimes[$j]</td>", @avgTimes[$j];
84 #print "\n$page\t\t@avgTimes[$j]\t@maxTimes[$j]\t@minTimes[$j]\t";
85 my $i;
86 for($i=0; $i < $num_tests; $i++){
87 print OUT "<td>$timeList[$j][$i]</td>";
89 print OUT "</tr>";
90 $j++;
92 print OUT "</TABLE><H4><I>Report Done</I></H4></BODY></HTML>";
95 sub GetTestList {
96 my ($list_file) = @_;
97 my @retval = ();
99 open (TESTLIST, $list_file) ||
100 die("Could not find test list file: '$list_file': $!\n");
102 while (<TESTLIST>) {
103 s/\n$//;
104 if (!(/\s*\#/)) {
105 # It's not a comment, so process it
106 push (@retval, $_);
107 $num_pages++;
111 close (TESTLIST);
112 return @retval;
115 sub usage {
116 print STDERR
117 ("\nusage: $0 NUM FILE LOC \n\n" .
118 "NUM Number of iterations you want\n" .
119 "FILE Location of input file containing test pages\n" .
120 "LOC Path (including executable) of TestPageLoad\n" .
121 " (should be in same directory as mozilla bin\n".
122 " ex: /builds/mozilla/dist/bin/TestPageLoad )\n\n");
123 exit (1);