michael@0: #neckoTiming.pl michael@0: # michael@0: # This file drives the Neck Page Load Timer. michael@0: # Written by John A. Taylor in 2001 michael@0: michael@0: use Strict; michael@0: michael@0: my @pageList; michael@0: my @fileList; michael@0: my @timeList; michael@0: my @minTimes; michael@0: my @maxTimes; michael@0: my @avgTimes; michael@0: my $file_name; # = "PageList_all_pages.txt"; michael@0: my $output_file = "timing_output.html"; michael@0: my $test_loc; # = " c:/builds/src/mozilla/dist/WIN32_O.OBJ/bin/TestPageLoad"; michael@0: my $test_com; michael@0: my $num_tests=1; michael@0: my $num_pages=0; michael@0: michael@0: if($#ARGV != 2){ michael@0: usage(@ARGV); michael@0: } michael@0: michael@0: $num_tests = $ARGV[0]; michael@0: $file_name = $ARGV[1]; michael@0: $test_loc = $ARGV[2]; michael@0: michael@0: push (@pageList, GetTestList($file_name)); michael@0: michael@0: my $i, $j, this; michael@0: for($i = 0; $i < $num_tests; $i++) { michael@0: $j=0; michael@0: foreach $page (@pageList) { michael@0: my $start, $finish, $total; michael@0: $test_com = $test_loc . " " . $page . " | "; michael@0: printf "Testing (%d/%d): $page\n",$i*$num_pages+$j+1, $num_tests * $num_pages; michael@0: # $start = (times)[0]; michael@0: open (TEST, $test_com) michael@0: || die ("Could not find test program: $test_loc"); michael@0: while() { michael@0: if(/>>PageLoadTime>>(\d*)>>/){ michael@0: print "$1\n"; michael@0: $this = $1/1000; michael@0: $timeList[$j][$i] = $this; michael@0: @avgTimes[$j] += $this; michael@0: if($this > @maxTimes[$j] || $i == 0) { michael@0: @maxTimes[$j] = $this; michael@0: } michael@0: if($this < @minTimes[$j] || $i == 0) { michael@0: @minTimes[$j] = $this; michael@0: } michael@0: } michael@0: } michael@0: $j++; michael@0: } michael@0: } michael@0: michael@0: for($i = 0; $i < $j; $i++) { michael@0: @avgTimes[$i] /= $num_tests; michael@0: } michael@0: michael@0: PrintReport(); michael@0: print "\nHTML formated report is in: timing_output.html\nin this directory\n"; michael@0: exit; michael@0: michael@0: my $num_cols = $num_tests + 4; michael@0: sub PrintReport { michael@0: my $j=0; michael@0: open (OUT, ">$output_file"); michael@0: print OUT "

Necko Timing Test Results

", michael@0: "Number of iterations: $num_tests", michael@0: "", michael@0: ""; michael@0: michael@0: foreach $page(@pageList) { michael@0: #$loc=$page; michael@0: #$max_time = @maxTimes[$j]; michael@0: #$min_time = @minTimes[$j]; michael@0: #$avg_time = @avgTimes[$j]; michael@0: #$time_1 = $timeList[$j][0]; michael@0: #write; michael@0: printf OUT "", @avgTimes[$j]; michael@0: #print "\n$page\t\t@avgTimes[$j]\t@maxTimes[$j]\t@minTimes[$j]\t"; michael@0: my $i; michael@0: for($i=0; $i < $num_tests; $i++){ michael@0: print OUT ""; michael@0: } michael@0: print OUT ""; michael@0: $j++; michael@0: } michael@0: print OUT "
Page LocationAvg TimeMax TimeMin TimeTimes ...
$page%d@maxTimes[$j]@minTimes[$j]$timeList[$j][$i]

Report Done

"; michael@0: } michael@0: michael@0: sub GetTestList { michael@0: my ($list_file) = @_; michael@0: my @retval = (); michael@0: michael@0: open (TESTLIST, $list_file) || michael@0: die("Could not find test list file: '$list_file': $!\n"); michael@0: michael@0: while () { michael@0: s/\n$//; michael@0: if (!(/\s*\#/)) { michael@0: # It's not a comment, so process it michael@0: push (@retval, $_); michael@0: $num_pages++; michael@0: } michael@0: } michael@0: michael@0: close (TESTLIST); michael@0: return @retval; michael@0: } michael@0: michael@0: sub usage { michael@0: print STDERR michael@0: ("\nusage: $0 NUM FILE LOC \n\n" . michael@0: "NUM Number of iterations you want\n" . michael@0: "FILE Location of input file containing test pages\n" . michael@0: "LOC Path (including executable) of TestPageLoad\n" . michael@0: " (should be in same directory as mozilla bin\n". michael@0: " ex: /builds/mozilla/dist/bin/TestPageLoad )\n\n"); michael@0: exit (1); michael@0: }