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