root/trunk/bps-html/bps-html

Revision 1, 14.5 kB (checked in by root, 3 years ago)

initial import

  • Property svn:executable set to
Line 
1 #!/usr/bin/perl -w
2
3 #Converts bps output log files to html documents
4 #Takes one argument, the directory containing the log files
5
6 $numargs=@ARGV;
7 if ($numargs!=1) {
8 printf "Error: Invalid arguments\n";
9 printusage();
10 exit 1;
11 }
12
13 $logdirname=$ARGV[0];
14 $logdirname=~s/\/[      ]*$//;
15
16 if (! -e $logdirname) {
17 printf "Error: %s does not exist\n",$logdirname;
18 printusage();
19 exit 1;
20 }
21
22 if (! -w $logdirname) {
23 printf "Error: %s is not writable\n",$logdirname;
24 printusage();
25 exit 1;
26 }
27
28 opendir(DIR, $logdirname);
29 @nasbname= grep { /^npb(\.\w+){3}\.\d+$/ } readdir(DIR);
30 closedir(DIR);
31 $count=0;
32
33 #nas log handling
34 foreach $naslog (@nasbname){
35         $naslogs[$count]="${logdirname}/${naslog}";
36         $count++;
37 }
38
39 #logfile handling
40 %logs = (
41     bonnie   =>   "${logdirname}/bonnie.log",
42     netpipe   =>   "${logdirname}/netpipe.log",
43     netperf   =>   "${logdirname}/netperf.log",
44     stream   =>   "${logdirname}/stream.log",
45     unixbench   =>   "${logdirname}/unixbench.log",
46     lmbench     =>      "${logdirname}/lmbench.log",
47 );
48
49 #basenames needed for file handling
50 %bname = (
51         bonnie => "bonnie.log",
52         netpipe => "netpipe.log",
53         netperf => "netperf.log",
54         stream => "stream.log",
55         unixbench => "unixbench.log",
56         lmbench => "lmbench.log",
57 );
58
59 #first handle NAS benchlogs
60 if (open(INDEX, ">${logdirname}/index.html")) {
61
62 InitIndex(INDEX);
63
64 $count=0;
65 foreach $filename (@naslogs) {
66         $logname=$nasbname[$count];
67         if ( open(LOG, $filename) ) {
68                 $htmlfile= $filename . ".html";
69    
70                 if (open(HTML,">" . $htmlfile )) {
71         printf "Generating: ${logname}.html\n";
72         printf INDEX "<LI><A HREF=\"" . $logname . ".html\">NAS Parallel:${logname} results</A>\n";
73  
74       PrintHTMLHeader(HTML, $logname);
75            
76       while ( <LOG> ) {
77                         next if /^\s*$/; # Ignore blank lines
78       
79                         if($_ =~ /\[.start.*NAS.*\]/) {
80                                 NAS(LOG, HTML, "NAS", $logname);
81                         } else { # no start header... don't know what to do
82                                 next    #s/\n/<BR>\n/g;
83                                 #printf HTML "%s", $_;
84                         }
85         }
86        
87                 PrintHTMLFooter(HTML, $logname);
88         }
89         close(HTML);   
90      }
91      $count++;
92 }
93
94 #handle all other bench logs
95 foreach $log (sort(keys %logs)) {
96         $filename=$logs{$log}; 
97         $logname=$bname{$log};
98
99         if ( open(LOG, $filename) ) {
100                 $htmlfile= $filename . ".html";
101    
102                 if (open(HTML,">" . $htmlfile )) {
103         printf "Generating: ${logname}.html\n";
104         printf INDEX "<LI><A HREF=\"" . $logname . ".html\">" . $log . " results</A>\n";
105  
106       PrintHTMLHeader(HTML, $logname);
107            
108       while ( <LOG> ) {
109                         next if /^\s*$/; # Ignore blank lines
110       
111         # s/\[.(start|end).*$log.*\]/<B>$&<\/B>/g;
112         # s/\]/\]<\/B>/g;
113       
114                         if($_ =~ /\[.start.*$log.*\]/) {
115                                 $log->(LOG, HTML, $log, $logname); # call the function named $log
116                         } else { # no start header... don't know what to do
117                                 next    #s/\n/<BR>\n/g;
118                                 #printf HTML "%s", $_;
119                         }
120                 }
121        
122                 PrintHTMLFooter(HTML, $logname);
123         }
124         close(HTML);   
125 }
126 else{
127         printf "$logname not found, no file generated\n";
128 }
129 close(LOG);
130 }
131
132 printf INDEX "</UL>\n";
133 PrintHTMLFooter(INDEX, "Beowulf Performance Suite Reult Index");
134
135 close(INDEX);
136 }
137
138 sub printusage{
139 printf("Usage: %s <log directory>\n\n", $0);
140 }
141
142 #benchmark specific functions, processes the output files
143 sub lmbench{
144    my ($file, $output, $benchname, $logfile) =@_;
145         while(<$file>) {
146                 my $line = $_ ;
147                 $line =~ s/\[.end.*$//;
148                 printf $output "${line}\n";
149         }
150    printf $output "%s", "<P>Click <A HREF=\"$logfile\">here</A> for full lmbench output.\n";
151 }
152
153 sub NAS{
154    my ($file, $output, $benchname, $logfile) = @_;
155    my %benchval ;
156    my $time=""; my $mopstot=""; my $mopsproc=""; my $program=""; my $info="";
157    printf $output "%s\n", "<CENTER>";
158    printf $output "%s\n", "<P><H1>NAS Results Summary</H1>";
159    printf $output "%s\n", "<TABLE BORDER=1>"; # table header
160    printf $output "%s\n", "<TR>" .
161                           "<TD><B>Test Name" .
162                           "<TD><B>MOPS Total" .
163                           "<TD><B>MOPS/CPU" .
164                           "<TD><B>Time</TR>";
165    while(<$file>) {
166        if(/^.*(Mop\/s\ total|Mop\/s\/process|Time|PROGRAM|Compiler:|MPI:|Processors:|Size:).*$/) {
167            my $line = $_ ;
168            my @temp = split;
169            if ($temp[0] eq "Compiler:")
170            {
171                 $info = $line;
172            }
173            if ($temp[0] eq "Time")
174            {
175                $time=$temp[4];
176            }
177            if ($temp[0] eq "Mop/s")
178            {
179                $mopstot=$temp[3];
180            }
181            if ($temp[0] eq "Mop/s/process")
182            {
183                $mopsproc=$temp[2];
184                if ($mopsproc ne "NOT") {
185                printf $output "\t<TR><TD>${program}<TD>${mopstot}<TD>${mopsproc}<TD>${time}</TR>\n";
186            }
187            }
188            if ($temp[1] eq "PROGRAM")
189            {
190                $program = $temp[2];
191            }
192         }
193    }
194    printf $output "%s", "</TABLE>\n"; # table footer
195    printf $output "${info}\n";
196    printf $output "%s\n", "</CENTER>";
197    printf $output "%s", "<P>Click <A HREF=\"$logfile\">here</A> for full NAS benchmarks output.\n";
198 }
199
200 sub bonnie{
201    my ($file, $output, $benchname, $logfile) = @_;
202    my %benchval ;
203    @bonnietests = ("Seq Output Per Chr", "Seq Output Block", "Seq Output Rewrite", "Seq Input Per Chr", "Seq Input Block", "Random Seeks","Seq Create","Seq Read","Seq Delete","Random Create","Random Read","Random Delete");
204    printf $output "%s\n", "<CENTER>";
205    printf $output "%s\n", "<P><H1>Bonnie Results Summary</H1>";
206    printf $output "%s\n", "<P><P>Data I/O Results";
207    printf $output "%s\n", "<TABLE BORDER=1>"; # table header
208    while(<$file>) {
209       if( /^.*\d\,\d.*$/ ) {
210          my $i = 0 ;
211          my $j = 0 ;
212          my $line = $_ ;
213          my $temp;
214          foreach $temp (split("," , $line)) {
215            if ($temp=~/^\s*\d.*$/) {
216             if($i == 0) {
217                 #$temp=~s/\D//;
218                printf $output "%s", "<TR>" .
219                "<TD BGCOLOR=BLACK><FONT COLOR=WHITE>${temp} file" ;
220                printf $output "%s\n", "<TD><B>kB/sec</B><TD><B>%CPU</B></TR>";
221             }
222             elsif($i == 13) {
223                printf $output "%s", "</TABLE>\n";
224                printf $output "%s\n", "<P><P>File Creation Results";
225                printf $output "%s\n", "<TABLE BORDER=1>"; # table header
226                printf $output "%s", "<TR>" .           
227                "<TD BGCOLOR=BLACK><FONT COLOR=WHITE>${temp} files" ;
228                printf $output "%s\n", "<TD><B>files/sec</B><TD><B>%CPU</B></TR>";
229                $i++;
230             }
231             else {
232                if($i % 2 == 1) {
233                   printf $output "%s", "<TR><TD>" . $bonnietests[$j] . "<TD>$temp</TD>";
234                   $j++;
235                } else {
236                    printf $output "%s\n", "<TD>$temp</TR>";
237                }
238             }
239             $i++;                     
240           }
241          }
242       }
243    }
244    printf $output "%s", "</TABLE>\n"; # table footer
245    printf $output "%s\n", "</CENTER>";
246    printf $output "%s", "<P>Click <A HREF=\"$logfile\">here</A> for full $benchname output.\n";
247 }
248
249 sub netpipe{
250    #next;
251    my $interface=0;
252    system ("cp /opt/bps/bin/netpipe.*.gp $logdirname");
253    system ("cd $logdirname; gnuplot netpipe.network_signature_graph.gp; gnuplot netpipe.throughput_vs_blocksize.gp");
254    system ("rm $logdirname/netpipe.*.gp");
255    my ($file, $output, $benchname, $logfile) = @_;
256    printf $output "%s\n", "<CENTER>";
257    printf $output "%s\n", "<P><H1>NetPipe TCP Results Summary</H1>";
258    printf $output "</CENTER>\n";
259    my $greatest=0;
260    my @line;
261    while(<$file>) {
262         next if /^\s*$/; # Ignore blank lines
263         my @temp = split ;
264         if ($temp[0] eq "Netpipe") {
265             $interface=$temp[2];
266         }
267         if ($temp[0] eq "Latency:") {
268                 printf $output "<P>%s %s (microseconds)\n",$temp[0],$temp[1];
269         }
270         if ($temp[6]) {
271                 if ($temp[6] >= $greatest) {
272                         $greatest = $temp[6];
273                         @line = @temp;
274                 }
275         }
276            
277    }
278    printf $output "<P>Interface: ${interface}\n";
279    printf $output "%s", "<P>Greatest throughput at <B>$greatest Mbps</B>:\n" .
280    "<BR>&nbsp;&nbsp;&nbsp;&nbsp;@line\n";
281    printf $output "%s","<BR><img src= \"netpipe.network_signature_graph.png\" border = \"5\" height=\"500\" width=\"700\" align=\"right,left,center\">\n";
282    printf $output "%s","<BR><img src=\"netpipe.throughput_vs_blocksize.png\" border = \"5\" height=\"500\" width=\"700\" align=\"right,left,center\">\n";
283    printf $output "%s", "<P>Click <A HREF=\"$logfile\">here</A> for full $benchname output.<BR>\n";
284
285 }
286
287 sub netperf{
288    #my @line = /^.*start netperf.*$/;
289    my ($file, $output, $benchname, $logfile) = @_;
290    my $interface=0;
291    printf $output "%s\n", "<CENTER>";
292    printf $output "%s\n", "<P><H1>NetPerf Results Summary</H1>";
293    printf $output "%s\n", "<TABLE BORDER=1>"; # table header
294    printf $output "%s\n", "<TR BGCOLOR=BLACK>" .
295         "<TD COLSPAN=6><FONT COLOR=WHITE><B>UDP Unidirectional Send Test</TR>";
296    printf $output "%s\n", "<TR BGCOLOR=BLACK>" .
297                         "<TD><FONT COLOR=WHITE>Socket Size<BR>(Bytes)" .
298                         "<TD><FONT COLOR=WHITE>Message Size<BR>(Bytes)" .
299                         "<TD><FONT COLOR=WHITE>Elapsed Time<BR>(Secs)" .
300                         "<TD><FONT COLOR=WHITE>Messages Okay<BR>(#)" .
301                         "<TD><FONT COLOR=WHITE>Message Errors<BR>(#)" .
302                         "<TD><FONT COLOR=WHITE>Throughput<BR>(10^6bits/sec)" .
303                         "</TR>\n";
304    my $state=0;
305    while(<$file>) {
306         next if /^\s*$/; # Ignore blank lines
307         if (/^\s*Netperf.*$/) {
308             my @temp = split;
309             $interface=$temp[2];
310         }
311         if (/^\s*TCP.*$/) {
312                 $state=1 ;
313                 printf $output "</TABLE>\n" . "<BR><BR>" . "<TABLE BORDER=1>\n";
314                 printf $output "%s\n", "<TR BGCOLOR=BLACK>" .
315                         "<TD COLSPAN=5><FONT COLOR=WHITE>" .
316                         "<B>TCP Stream Test</B>" . "</TR>";
317                 printf $output "%s\n", "<TR BGCOLOR=BLACK>" .
318                         "<TD><FONT COLOR=WHITE>Recv Socket Size<BR>(Bytes)" .
319                         "<TD><FONT COLOR=WHITE>Send Socket Size<BR>(Bytes)" .
320                         "<TD><FONT COLOR=WHITE>Send Message Size<BR>(Bytes)" .
321                         "<TD><FONT COLOR=WHITE>Elapsed Time<BR>(Secs)" .
322                         "<TD><FONT COLOR=WHITE>Throughput<BR>(10^6bits/sec)" .
323                         "</TR>";
324         }
325         if($state==0) {
326                 if(/^\s*(\d+(\.\d+)?\s*){1,6}$/) {
327                         printf $output "<TR>";
328                         my @temp = split ;
329                         if(scalar(@temp)==4) {
330                                 printf $output
331                                 "<TD>%s<TD><TD>%s<TD>%s<TD><TD><B>%s", @temp ;
332                         } else {
333                                 printf $output
334                                 "<TD>%s<TD>%s<TD>%s<TD>%s<TD><FONT " .
335                                 "COLOR=RED>%s<TD><B>%s", @temp;
336                         }
337                         printf $output "</TR>\n";
338                 }
339         } else {
340                 if(/^\s*(\d+(\.\d+)?\s*){1,6}$/) {
341                         printf $output "<TR>";
342                         my $x=0;
343                         foreach(split) {
344                                 $x++;
345                                 if($x==5) {
346                                         printf $output "<TD><B>%s", $_;
347                                 } else {
348                                         printf $output "<TD>%s", $_;
349                                 }
350                         }
351                         printf $output "</TR>\n";
352                 }
353         }
354    }
355    printf $output "%s", "</TABLE>\n"; # table footer
356    printf $output "<P>Interface: ${interface}\n";
357    printf $output "%s\n", "</CENTER>";
358    printf $output "%s", "<P>Click <A HREF=\"$logfile\">here</A> for full $benchname output.\n";
359 }
360
361 sub stream{
362    my ($file, $output, $benchname, $logfile) = @_;
363    my @temp;
364    printf $output "%s\n", "<CENTER>";
365    printf $output "%s\n", "<P><H1>Stream Results Summary</H1>";
366    printf $output "%s\n", "<TABLE BORDER=1>";
367    printf $output "%s\n", "<TR>" .
368                           "<TD><B>Function" .
369                           "<TD><B>Rate (MB/s)" .
370                           "<TD><B>RMS time" .
371                           "<TD><B>Min time" .
372                           "<TD><B>Max time</TR>";
373    while(<$file>) {
374       if(/^\s*(Array size|Total memory required).*$/) {
375         push  (@temp,$_)
376       }
377       if(/^\s*(Copy|Scale|Add|Triad)\d?.*$/) {
378          my $i=0;
379          printf $output "%s", "\t<TR>";
380          foreach (split) {
381             if ($i==0) { s/://g ; } # remove the :
382             printf $output "%s", "<TD>$_";
383             $i++;
384          }
385          printf $output "%s\n", "</TR>";
386       }
387    }
388    printf $output "%s\n", "</TABLE>"; # table footer
389    foreach $line (@temp) {
390         printf $output "<P>${line}\n";
391    }
392    printf $output "%s\n", "</CENTER>";
393    printf $output "%s", "<P>Click <A HREF=\"$logfile\">here</A> for full $benchname output.\n";
394 }
395
396 sub unixbench{
397    my ($file, $output, $benchname, $logfile) = @_;
398    printf $output "%s\n", "<CENTER>";
399    printf $output "%s\n", "<P><H1>UnixBench Results Summary</H1>";
400    printf $output "%s\n", "<TABLE BORDER=1>";
401    printf $output "%s\n", "<TR>" .
402                           "<TD><B>Test" .
403                           "<TD><B>Baseline" .
404                           "<TD><B>Result" .
405                           "<TD><B>Index";
406    while (<$file>) {
407       if(/^.*\s?\d?\.\d$/) {
408          my @temp = split ;
409          if (/FINAL\sSCORE.*$/) {
410             $temp[-2] .= "<TD ALIGN=RIGHT>" ;
411             printf $output "%s\n", "<TR><TD COLSPAN=3><B>@temp";
412          } else {
413             # s/\d?\.\d/<TD>$&/g ;
414             $temp[-2] .= "<TD ALIGN=RIGHT>";
415             $temp[-3] .= "<TD ALIGN=RIGHT>";
416             $temp[-4] .= "<TD ALIGN=RIGHT>";
417             printf $output "%s\n", "\t<TR><TD>@temp</TR>";
418          }
419       }
420    }
421    printf $output "%s\n", "</TABLE>"; # table footer
422    printf $output "%s\n", "</CENTER>";
423    printf $output "%s", "<P>Click <A HREF=\"$logfile\">here</A> for full $benchname output.\n";
424 }
425
426 #header and footer functions for general benchmark html files
427 sub PrintHTMLHeader {
428    my ( $file, $title ) = @_ ;
429    printf $file "<!DOCTYPE HTML PUBLIC\"-//W3C//DTD HTML 3.2 Final//EN\">\n";
430    printf $file "<HTML>\n<HEAD>\n<TITLE>" . $title . "</TITLE>\n</HEAD>\n<BODY BGCOLOR=WHITE>\n";
431 }
432
433 sub PrintHTMLFooter {
434    # $title not needed... just in for consistency of function calls
435    my ( $file, $title ) = @_ ;
436    printf $file "</BODY>\n</HTML>\n";
437 }
438
439 #Initialization function for html files
440 sub InitIndex {
441    my ($index) = @_;
442    my $line;
443    my @templine;
444    PrintHTMLHeader($index, "Beowulf Performance Suite Results");
445    printf $index "<P><B><H1>Beowulf Performance Suite Results</H1></B>\n";
446    printf $index "Generated on ". `date +%Y-%m-%d` .
447            " at " . `date +%H:%M` . " by Beowulf Performance Suite</A><P>\n";
448    printf $index "<P><B>Beowulf Performance Suite.</B> <br>";
449    printf $index "Test suite information is available <A HREF=\"/usr/share/doc/bps-1.4/tests.html\">here</A>.<br> License information is available <A HREF=\"/usr/share/doc/bps-1.4/LICENSE\">here.</A></P>\n";
450 printf $index "<B>Machine Data:</B>\n";
451    my $machine = "${logdirname}/machine.data";
452    my $cpuNumber=1;
453    my $cpumhzNumber=1;
454    if (open(FILE, $machine)) {
455    printf $index "%s\n", "<TABLE BORDER=1>";
456     while (<FILE>) {
457         if(/^\s*(Motherboard|Memory:|Interconnects:|Linux Version:).*$/) {
458             $line=$_;
459             $line=~s/: /<TD>/;
460         }
461         else {
462             $line=$_;
463             @templine = split;
464             if ($templine[0] eq "model") {
465                 $line=~s/model name/CPU ${cpuNumber} Model/;
466                 $line=~s/: /<TD>/;
467                 $cpuNumber++;
468             }
469             elsif($templine[0] eq "cpu") {
470                 $line=~s/cpu/CPU ${cpumhzNumber}/;
471                 $line=~s/: /<TD>/;
472                 $cpumhzNumber++;
473             }
474             else {
475                 $line = "Machine Name <TD>${templine[1]}<TR><TD>Kernel<TD>${templine[2]}";         
476             }
477         }
478         printf $index "<TR><TD>%s</TR>\n", $line;
479     }
480    printf $index "</TABLE>\n";
481    printf $index "<P><B>Benchmarks:</B>\n";
482    printf $index "<UL>\n";
483   }
484 }
485
486
487
488
489
490
491
492
493
Note: See TracBrowser for help on using the browser.