: eval 'exec perl -S $0 ${1+"$@"}' if 0; # Copyright (C) 2000-2001, 2003 MySQL AB # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; version 2 # of the License. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, # MA 02111-1307, USA # # a little program to generate a table of results # just read all the RUN-*.log files and format them nicely # Made by Luuk de Boer # Patched by Monty use Getopt::Long; $opt_server="mysql"; $opt_dir="output"; $opt_machine=$opt_cmp=""; $opt_relative=$opt_same_server=$opt_help=$opt_Information=$opt_skip_count=$opt_no_bars=$opt_verbose=0; GetOptions("Information","help","server=s","cmp=s","machine=s","relative","same-server","dir=s","skip-count","no-bars","html","verbose") || usage(); usage() if ($opt_help || $opt_Information); $opt_cmp=lc(join(",",sort(split(',',$opt_cmp)))); if ($opt_same_server) { $files="$opt_dir/RUN-$opt_server*$opt_machine"; } else { $files="$opt_dir/RUN-*$opt_machine"; } $files.= "-cmp-$opt_cmp" if (length($opt_cmp)); # # Go trough all RUN files and gather statistics. # if ($#ARGV == -1) { @ARGV=glob($files); $automatic_files=1; } foreach (@ARGV) { next if (!$opt_cmp && /-cmp-/ && $automatic_files || defined($found{$_})); $prog=$filename = $_; $found{$_}=1; # Remove dupplicates /RUN-(.*)$/; $tot{$prog}{'version'}=$1; push(@key_order,$prog); $next = 0; open(TMP, "<$filename") || die "Can't open $filename: $!\n"; while () { chomp; if ($next == 0) { if (/Server version:\s+(\S+.*)/i) { $tot{$prog}{'server'} = $1; } elsif (/Arguments:\s+(.+)/i) { $arguments= $1; # Remove some standard, not informative arguments $arguments =~ s/--force|--log|--use-old\S*|--server=\S+|--cmp=\S+|--user=\S+|--pass=\S+|--machine=\S+|--dir=\S+//g; if (($tmp=index($arguments,"--comment")) >= 0) { if (($end=index($arguments,$tmp+2,"--")) >= 0) { substr($arguments,$tmp,($end-$tmp))=""; } else { $arguments=substr($arguments,0,$tmp); } } $arguments =~ s/\s+/ /g; $tot{$prog}{'arguments'}=$arguments; } elsif (/Comments:\s+(.+)/i) { $tot{$prog}{'comments'} = $1; } elsif (/^(\S+):.*(estimated\s|)total\stime:\s+([\d.]+)\s+(wallclock\s|)secs/i) { $tmp = $1; $tmp =~ s/://; $tot{$prog}{$tmp} = [ $3, (length($2) ? "+" : "")]; $op1{$tmp} = $tmp; } elsif (/Totals per operation:/i) { $next = 1; next; } } elsif ($next == 1) { if (/^(\S+)\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\s*([+|?])*/) { $tot1{$prog}{$1} = [$2,$6,$7]; $op{$1} = $1; } } } } if (!%op) { print "Didn't find any files matching: '$files'\n"; print "Use the --cmp=server,server option to compare benchmarks\n"; exit 1; } # everything is loaded ... # now we have to create a fancy output :-) # I prefer to redirect scripts instead to force it to file ; Monty # # open(RES, ">$resultfile") || die "Can't write to $resultfile: $!\n"; # select(RES) # if ($opt_html) { html_output(); } else { ascii_output(); } exit 0; # # some output + format functions; # sub ascii_output { print <[0],undef(),$tot{$server}{$key}->[1]); $first=$tot{$server}{$key}->[0] if (!defined($first)); } print "\n"; } print_sep("-"); print_string("The results per operation:"); print_sep("-"); foreach $key (sort {$a cmp $b} keys %op) { next if ($key =~ /TOTALS/i); $tmp=$key; $count=$tot1{$key_order[0]}{$key}->[1]; $tmp.= " (" . $count . ")" if (!$skip_count); printf "%-$namewidth.${namewidth}s${bar}", $tmp; $first=undef(); foreach $server (@key_order) { $tmp= $count != $tot1{$server}{$key}->[1] ? "*" : ""; print_value($first,$tot1{$server}{$key}->[0],$tot1{$server}{$key}->[1], $tot1{$server}{$key}->[2] . $tmp); $first=$tot1{$server}{$key}->[0] if (!defined($first)); } print "\n"; } print_sep("-"); $key="TOTALS"; printf "%-$namewidth.${namewidth}s${bar}", $key; $first=undef(); foreach $server (@key_order) { print_value($first,$tot1{$server}{$key}->[0],undef(), $tot1{$server}{$key}->[2]); $first=$tot1{$server}{$key}->[0] if (!defined($first)); } print "\n"; print_sep("="); } sub html_output { my $template="template.html"; my $title="MySQL | | Information | Benchmarks | Compare with $opt_cmp"; my $image="info.gif"; $bar=""; open(TEMPLATE, $template) || die; while (