mariadb/sql-bench/graph-compare-results.sh

661 lines
22 KiB
Bash
Raw Normal View History

Added back sql-bench directory, so that one can more easily run benchmarks on a server and add new benchmarks for new optimizations Fixed memory leak in _db_set() (Bug#24497 Valgrind warning: get_one_option) Don't call net_clear() on COM_QUIT. This avoids a warning from net_clear() after shutdown: "skipped ## bytes from file" BUG#21428: skipped 9 bytes from file: socket (3)" on "mysqladmin shutdown" sql-bench/test-wisconsin.sh: Rename: BitKeeper/deleted/.del-test-wisconsin.sh~c0b86821b5f95f26 -> sql-bench/test-wisconsin.sh sql-bench/test-transactions.sh: Rename: BitKeeper/deleted/.del-test-transactions.sh~c1c892f10c40caf -> sql-bench/test-transactions.sh sql-bench/test-insert.sh: Rename: BitKeeper/deleted/.del-test-insert.sh~893bfac9dedb79a7 -> sql-bench/test-insert.sh sql-bench/test-select.sh: Rename: BitKeeper/deleted/.del-test-select.sh~6d5cc770acf11be6 -> sql-bench/test-select.sh sql-bench/test-create.sh: Rename: BitKeeper/deleted/.del-test-create.sh~f9a1ea38c191b17a -> sql-bench/test-create.sh sql-bench/test-big-tables.sh: Rename: BitKeeper/deleted/.del-test-big-tables.sh~5b1b0c5fb623565a -> sql-bench/test-big-tables.sh sql-bench/test-connect.sh: Rename: BitKeeper/deleted/.del-test-connect.sh~382a728c949ee075 -> sql-bench/test-connect.sh sql-bench/test-ATIS.sh: Rename: BitKeeper/deleted/.del-test-ATIS.sh~e8ebff7086c95773 -> sql-bench/test-ATIS.sh sql-bench/test-alter-table.sh: Rename: BitKeeper/deleted/.del-test-alter-table.sh~eba6cfa9972fcced -> sql-bench/test-alter-table.sh sql-bench/innotest2b.sh: Rename: BitKeeper/deleted/.del-innotest2b.sh~7b99ece835e8dff3 -> sql-bench/innotest2b.sh sql-bench/run-all-tests.sh: Rename: BitKeeper/deleted/.del-run-all-tests.sh~41d6da1cf211ee95 -> sql-bench/run-all-tests.sh sql-bench/innotest2.sh: Rename: BitKeeper/deleted/.del-innotest2.sh~9c14df528285603 -> sql-bench/innotest2.sh sql-bench/innotest2a.sh: Rename: BitKeeper/deleted/.del-innotest2a.sh~e01d016a7cafdc0b -> sql-bench/innotest2a.sh sql-bench/innotest1a.sh: Rename: BitKeeper/deleted/.del-innotest1a.sh~c64f4610ae1e26fe -> sql-bench/innotest1a.sh sql-bench/innotest1b.sh: Rename: BitKeeper/deleted/.del-innotest1b.sh~aafd0819ae84da7b -> sql-bench/innotest1b.sh sql-bench/innotest1.sh: Rename: BitKeeper/deleted/.del-innotest1.sh~aa36bce09ca783c7 -> sql-bench/innotest1.sh sql-bench/crash-me.sh: Rename: BitKeeper/deleted/.del-crash-me.sh~2fa881d0b40339c8 -> sql-bench/crash-me.sh sql-bench/graph-compare-results.sh: Rename: BitKeeper/deleted/.del-graph-compare-results.sh~7e4e28b3591b4542 -> sql-bench/graph-compare-results.sh sql-bench/copy-db.sh: Rename: BitKeeper/deleted/.del-copy-db.sh~e8116afb93144ccd -> sql-bench/copy-db.sh sql-bench/compare-results.sh: Rename: BitKeeper/deleted/.del-compare-results.sh~a9e26e2644c694b3 -> sql-bench/compare-results.sh sql-bench/bench-count-distinct.sh: Rename: BitKeeper/deleted/.del-bench-count-distinct.sh~a92f174271a831d7 -> sql-bench/bench-count-distinct.sh sql-bench/as3ap.sh: Rename: BitKeeper/deleted/.del-as3ap.sh~f54eebbd8d34c9b6 -> sql-bench/as3ap.sh sql-bench/Comments/Informix.crash-me: Rename: BitKeeper/deleted/.del-Informix.crash-me~51ab5b717cefe74 -> sql-bench/Comments/Informix.crash-me sql-bench/Comments/postgres.crash-me: Rename: BitKeeper/deleted/.del-postgres.crash-me~eacac145c3e30f17 -> sql-bench/Comments/postgres.crash-me sql-bench/Comments/Empress.crash-me: Rename: BitKeeper/deleted/.del-Empress.crash-me~bdaff0c68ce10f02 -> sql-bench/Comments/Empress.crash-me sql-bench/Comments/Adabas.crash-me: Rename: BitKeeper/deleted/.del-Adabas.crash-me~ce88ba1a540971ac -> sql-bench/Comments/Adabas.crash-me sql-bench/Comments/Access.crash-me: Rename: BitKeeper/deleted/.del-Access.crash-me~bb457ec282d939b6 -> sql-bench/Comments/Access.crash-me sql-bench/Comments/postgres.benchmark: Rename: BitKeeper/deleted/.del-postgres.benchmark~4d30890732b784a -> sql-bench/Comments/postgres.benchmark sql-bench/Comments/mysql.benchmark: Rename: BitKeeper/deleted/.del-mysql.benchmark~4d8729c0937456fc -> sql-bench/Comments/mysql.benchmark sql-bench/Comments/FrontBase.benchmark: Rename: BitKeeper/deleted/.del-FrontBase.benchmark~217041ef18274c2e -> sql-bench/Comments/FrontBase.benchmark sql-bench/Comments/interbase: Rename: BitKeeper/deleted/.del-interbase~cdad59622b4d6f3 -> sql-bench/Comments/interbase sql-bench/uname.bat: Rename: BitKeeper/deleted/.del-uname.bat~a6d933d2ee9314c -> sql-bench/uname.bat sql-bench/pwd.bat: Rename: BitKeeper/deleted/.del-pwd.bat~9b64050849abf51 -> sql-bench/pwd.bat sql-bench/example.bat: Rename: BitKeeper/deleted/.del-example.bat~22d0170bccf0f030 -> sql-bench/example.bat sql-bench/Makefile.am: Rename: BitKeeper/deleted/.del-Makefile.am~7b07da85b2e9375 -> sql-bench/Makefile.am sql-bench/Data/ATIS/transport.txt: Rename: BitKeeper/deleted/.del-transport.txt~fa4ca40735f8354c -> sql-bench/Data/ATIS/transport.txt sql-bench/Data/ATIS/time_zone.txt: Rename: BitKeeper/deleted/.del-time_zone.txt~4171f9ca732f65c0 -> sql-bench/Data/ATIS/time_zone.txt sql-bench/Data/Wisconsin/tenk.data: Rename: BitKeeper/deleted/.del-tenk.data~6aeaebdd534e458e -> sql-bench/Data/Wisconsin/tenk.data sql-bench/Data/Wisconsin/onek.data: Rename: BitKeeper/deleted/.del-onek.data~6cd1edaf596a7f7 -> sql-bench/Data/Wisconsin/onek.data sql-bench/Data/ATIS/stop1.txt: Rename: BitKeeper/deleted/.del-stop1.txt~f09ba164ad44a288 -> sql-bench/Data/ATIS/stop1.txt sql-bench/Data/ATIS/time_interval.txt: Rename: BitKeeper/deleted/.del-time_interval.txt~a1def62e267a59b2 -> sql-bench/Data/ATIS/time_interval.txt sql-bench/Data/ATIS/stop.txt: Rename: BitKeeper/deleted/.del-stop.txt~31fb564e1f415e34 -> sql-bench/Data/ATIS/stop.txt sql-bench/Data/ATIS/restriction.txt: Rename: BitKeeper/deleted/.del-restriction.txt~6ae208924617784a -> sql-bench/Data/ATIS/restriction.txt sql-bench/Data/ATIS/state.txt: Rename: BitKeeper/deleted/.del-state.txt~9dd470ce14075b90 -> sql-bench/Data/ATIS/state.txt sql-bench/Data/ATIS/restrict_class.txt: Rename: BitKeeper/deleted/.del-restrict_class.txt~2f741bf0ea498f84 -> sql-bench/Data/ATIS/restrict_class.txt sql-bench/Data/ATIS/month_name.txt: Rename: BitKeeper/deleted/.del-month_name.txt~4c44f7a323d57d92 -> sql-bench/Data/ATIS/month_name.txt sql-bench/Data/ATIS/restrict_carrier.txt: Rename: BitKeeper/deleted/.del-restrict_carrier.txt~925b5492f3f9cba3 -> sql-bench/Data/ATIS/restrict_carrier.txt sql-bench/Data/ATIS/ground_service.txt: Rename: BitKeeper/deleted/.del-ground_service.txt~1087e477e86e84c -> sql-bench/Data/ATIS/ground_service.txt sql-bench/Data/ATIS/food_service.txt: Rename: BitKeeper/deleted/.del-food_service.txt~66d95a150c28458 -> sql-bench/Data/ATIS/food_service.txt sql-bench/Data/ATIS/flight_day.txt: Rename: BitKeeper/deleted/.del-flight_day.txt~76868d6d265d441e -> sql-bench/Data/ATIS/flight_day.txt sql-bench/Data/ATIS/flight_fare.txt: Rename: BitKeeper/deleted/.del-flight_fare.txt~d7322593c8530487 -> sql-bench/Data/ATIS/flight_fare.txt sql-bench/Data/ATIS/flight_class.txt: Rename: BitKeeper/deleted/.del-flight_class.txt~1801101474c29098 -> sql-bench/Data/ATIS/flight_class.txt sql-bench/Data/ATIS/fconnection.txt: Rename: BitKeeper/deleted/.del-fconnection.txt~e0ef6a8b5560a713 -> sql-bench/Data/ATIS/fconnection.txt sql-bench/Data/ATIS/flight.txt: Rename: BitKeeper/deleted/.del-flight.txt~e5065423760e99eb -> sql-bench/Data/ATIS/flight.txt sql-bench/Data/ATIS/fare.txt: Rename: BitKeeper/deleted/.del-fare.txt~ea0652f490bc24a6 -> sql-bench/Data/ATIS/fare.txt sql-bench/Data/ATIS/day_name.txt: Rename: BitKeeper/deleted/.del-day_name.txt~f813b215955d894c -> sql-bench/Data/ATIS/day_name.txt sql-bench/Data/ATIS/dual_carrier.txt: Rename: BitKeeper/deleted/.del-dual_carrier.txt~a7dd776224fbd92b -> sql-bench/Data/ATIS/dual_carrier.txt sql-bench/Data/ATIS/date_day.txt: Rename: BitKeeper/deleted/.del-date_day.txt~4e9a282fcf54cfd8 -> sql-bench/Data/ATIS/date_day.txt sql-bench/Data/ATIS/compound_class.txt: Rename: BitKeeper/deleted/.del-compound_class.txt~d4a2f1b7f96340b9 -> sql-bench/Data/ATIS/compound_class.txt sql-bench/Data/ATIS/connect_leg.txt: Rename: BitKeeper/deleted/.del-connect_leg.txt~f97b6e94e108bb36 -> sql-bench/Data/ATIS/connect_leg.txt sql-bench/Data/ATIS/code_description.txt: Rename: BitKeeper/deleted/.del-code_description.txt~f9117373e438b0e2 -> sql-bench/Data/ATIS/code_description.txt sql-bench/Data/ATIS/city.txt: Rename: BitKeeper/deleted/.del-city.txt~d96dd6d073344d2e -> sql-bench/Data/ATIS/city.txt sql-bench/Data/ATIS/class_of_service.txt: Rename: BitKeeper/deleted/.del-class_of_service.txt~21f6b9848b8c76d -> sql-bench/Data/ATIS/class_of_service.txt sql-bench/Data/ATIS/airport_service.txt: Rename: BitKeeper/deleted/.del-airport_service.txt~6ee6d5b852b3e38 -> sql-bench/Data/ATIS/airport_service.txt sql-bench/Data/ATIS/airline.txt: Rename: BitKeeper/deleted/.del-airline.txt~a79f8eadf853f2c8 -> sql-bench/Data/ATIS/airline.txt sql-bench/Data/ATIS/airport.txt: Rename: BitKeeper/deleted/.del-airport.txt~59c78514130e1f45 -> sql-bench/Data/ATIS/airport.txt sql-bench/Data/ATIS/aircraft.txt: Rename: BitKeeper/deleted/.del-aircraft.txt~15e4de7ab37c92d3 -> sql-bench/Data/ATIS/aircraft.txt sql-bench/TODO: Rename: BitKeeper/deleted/.del-TODO~cac6d7a63c426ae5 -> sql-bench/TODO sql-bench/limits/sybase.cfg: Rename: BitKeeper/deleted/.del-sybase.cfg~c4636b12767b3f14 -> sql-bench/limits/sybase.cfg sql-bench/limits/solid-nt4.cfg: Rename: BitKeeper/deleted/.del-solid-nt4.cfg~cca779f0c9e29d31 -> sql-bench/limits/solid-nt4.cfg sql-bench/limits/solid.cfg: Rename: BitKeeper/deleted/.del-solid.cfg~5ae0e4342eadb0fb -> sql-bench/limits/solid.cfg sql-bench/limits/pg.cfg: Rename: BitKeeper/deleted/.del-pg.cfg~db59cf39a5d417be -> sql-bench/limits/pg.cfg sql-bench/limits/mysql.cfg: Rename: BitKeeper/deleted/.del-mysql.cfg~9cab20a8771b93cf -> sql-bench/limits/mysql.cfg sql-bench/limits/oracle.cfg: Rename: BitKeeper/deleted/.del-oracle.cfg~affab21af8f438fd -> sql-bench/limits/oracle.cfg sql-bench/limits/mysql-4.1.cfg: Rename: BitKeeper/deleted/.del-mysql-4.1.cfg~b6c5e74aefc99e3c -> sql-bench/limits/mysql-4.1.cfg sql-bench/limits/mysql-3.23.cfg: Rename: BitKeeper/deleted/.del-mysql-3.23.cfg~3cf9d6be54b77a3c -> sql-bench/limits/mysql-3.23.cfg sql-bench/limits/mysql-4.0.cfg: Rename: BitKeeper/deleted/.del-mysql-4.0.cfg~6c9d63c85b5ef574 -> sql-bench/limits/mysql-4.0.cfg sql-bench/limits/mysql-3.22.cfg: Rename: BitKeeper/deleted/.del-mysql-3.22.cfg~e706f26a161175cd -> sql-bench/limits/mysql-3.22.cfg sql-bench/limits/msql.cfg: Rename: BitKeeper/deleted/.del-msql.cfg~52710b12932cceb9 -> sql-bench/limits/msql.cfg sql-bench/limits/ms-sql65.cfg: Rename: BitKeeper/deleted/.del-ms-sql65.cfg~6b9bc3c460dbee05 -> sql-bench/limits/ms-sql65.cfg sql-bench/limits/mimer.cfg: Rename: BitKeeper/deleted/.del-mimer.cfg~234e6c1c3c47b612 -> sql-bench/limits/mimer.cfg sql-bench/limits/ms-sql.cfg: Rename: BitKeeper/deleted/.del-ms-sql.cfg~1907964264d2786a -> sql-bench/limits/ms-sql.cfg sql-bench/limits/interbase.cfg: Rename: BitKeeper/deleted/.del-interbase.cfg~c6951a0376cc6ff3 -> sql-bench/limits/interbase.cfg sql-bench/limits/interbase-dialect3.cfg: Rename: BitKeeper/deleted/.del-interbase-dialect3.cfg~46277bdfc74c667a -> sql-bench/limits/interbase-dialect3.cfg sql-bench/limits/interbase-superserver.cfg: Rename: BitKeeper/deleted/.del-interbase-superserver.cfg~22501198689243b0 -> sql-bench/limits/interbase-superserver.cfg sql-bench/limits/interbase-dialect1.cfg: Rename: BitKeeper/deleted/.del-interbase-dialect1.cfg~659206b5b9a11036 -> sql-bench/limits/interbase-dialect1.cfg sql-bench/limits/empress.cfg: Rename: BitKeeper/deleted/.del-empress.cfg~1f97f34d6560a499 -> sql-bench/limits/empress.cfg sql-bench/limits/frontbase.cfg: Rename: BitKeeper/deleted/.del-frontbase.cfg~71369e9c002696e -> sql-bench/limits/frontbase.cfg sql-bench/limits/db2.cfg: Rename: BitKeeper/deleted/.del-db2.cfg~711099b4d7906959 -> sql-bench/limits/db2.cfg sql-bench/limits/access.cfg: Rename: BitKeeper/deleted/.del-access.cfg~5239ea3655b7bba0 -> sql-bench/limits/access.cfg sql-bench/limits/access_odbc.cfg: Rename: BitKeeper/deleted/.del-access_odbc.cfg~34b4cf0eda56c4b1 -> sql-bench/limits/access_odbc.cfg sql-bench/limits/Informix.cfg: Rename: BitKeeper/deleted/.del-Informix.cfg~b94188e1ececb51b -> sql-bench/limits/Informix.cfg sql-bench/limits/Adabas.cfg: Rename: BitKeeper/deleted/.del-Adabas.cfg~343ed4e7f8b02111 -> sql-bench/limits/Adabas.cfg sql-bench/README: Rename: BitKeeper/deleted/.del-README~b1aa0c1bf9f5eb5e -> sql-bench/README BitKeeper/deleted/.del-create-pg_fast-Linux_2.2.14_my_SMP_i686-crashed: Delete: sql-bench/Results/create-pg_fast-Linux_2.2.14_my_SMP_i686-crashed Makefile.am: Added back sql-bench configure.in: Added back sql-bench dbug/dbug.c: Fixed memory leak in _db_set() This is not a complete fix as we can still get memory leaks if we do any of the following: mysqld --debug --debug CAll DBUG_SET or DBUG_SET_INITIAL more than once in a program Use SET @@global.debug=xxxx At some point we should fix the above, but this is not critical for normal operation (only for debugging) Bug #24497 Valgrind warning: get_one_option Note that all changes to _db_set_ is only a variable access change, and can be ignored while reviewing the bug fix. mysql-test/t/flush_read_lock_kill-master.opt: Added '+' to option, to be able to use this together with --debug mysql-test/valgrind.supp: Removed warning that is now fixed mysys/ptr_cmp.c: Fixed wrong pointer read (probably never used) scripts/make_binary_distribution.sh: Added back sql_bench sql/field.h: Removed class function that was identical in parent class sql/mysqld.cc: Removed some calls to my_thread_init() / my_thread_end() that was not needed. Only call DBUG_SET_INITAL, not DBUG_SET (Fixes memory leak in dbug) Mark some code as deadcode sql/net_serv.cc: Add information about from where error comes sql-bench/bench-init.pl.sh: Cleaned up help text sql-bench/server-cfg.sh: Don't write '/' after server name of no ssl version sql-common/client.c: Don't call net_clear() on COM_QUIT. This avoids a warning from net_clear() after shutdown: "skipped ## bytes from file" BUG#21428: skipped 9 bytes from file: socket (3)" on "mysqladmin shutdown" sql/sql_parse.cc: Added comment sql/table.h: Removed compiler warning
2006-11-29 21:51:09 +01:00
####
#### Hello ... this is a heavily hacked script by Luuk
#### instead of printing the result it makes a nice gif
#### when you want to look at the code ... beware of the
#### ugliest code ever seen .... but it works ...
#### and that's sometimes the only thing you want ... isn't it ...
#### as the original script ... Hope you like it
####
#### Greetz..... Luuk de Boer 1997.
####
## if you want the seconds behind the bar printed or not ...
## or only the one where the bar is too big for the graph ...
## look at line 535 of this program and below ...
## look in sub calculate for allmost all hard/soft settings :-)
# 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;
use GD;
$opt_server="mysql";
$opt_cmp="mysql,pg,solid";
$opt_cmp="msql,mysql,pg,solid";
$opt_cmp="empress,mysql,pg,solid";
$opt_dir="output";
$opt_machine="";
$opt_relative=$opt_same_server=$opt_help=$opt_Information=$opt_skip_count=0;
GetOptions("Information","help","server=s","cmp=s","machine=s","relative","same-server","dir=s","skip-count") || usage();
usage() if ($opt_help || $opt_Information);
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));
$automatic_files=0;
if ($#ARGV == -1)
{
@ARGV=glob($files);
$automatic_files=1;
}
#
# Go trough all RUN files and gather statistics.
#
foreach (@ARGV)
{
$filename = $_;
next if (defined($found{$_})); # remove duplicates
$found{$_}=1;
/RUN-(.*)$/;
$prog = $1;
push(@key_order,$prog);
$next = 0;
open(TMP, "<$filename") || die "Can't open $filename: $!\n";
while (<TMP>)
{
chomp;
if ($next == 0) {
if (/Server version:\s+(\S+.*)/i)
{
$tot{$prog}{'server'} = $1;
}
elsif (/Arguments:\s+(.+)/i)
{
$tot{$prog}{'arguments'} = $1;
# Remove some standard, not informative arguments
$tot{$prog}{'arguments'} =~ s/--log|--use-old-results|--server=\S+|--cmp=\S+|--user=\S+|--pass=\S+|--machine=\S+//g;
$tot{$prog}{'arguments'} =~ s/\s+/ /g;
}
elsif (/Comments:\s+(.+)/i) {
$tot{$prog}{'comments'} = $1;
} elsif (/^(\S+):\s*(estimated\s|)total\stime:\s+(\d+)\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;
#print "TEST - $_ \n * $prog - $1 - $2 - $6 - $7 ****\n";
# $prog - filename
# $1 - operation
# $2 - time in secs
# $6 - number of loops
# $7 - nothing / + / ? / * => estimated time ...
# get the highest value ....
$highest = ($2/$6) if (($highest < ($2/$6)) && ($1 !~/TOTALS/i));
$gifcount++;
$giftotal += ($2/$6);
}
}
}
}
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)
#
#print <<EOF;
#<cut for this moment>
#
#EOF
if ($opt_relative)
{
# print "Column 1 is in seconds. All other columns are presented relative\n";
# print "to this. 1.00 is the same, bigger numbers indicates slower\n\n";
}
#print "The result logs which where found and the options:\n";
if ($automatic_files)
{
if ($key_order[$i] =~ /^$opt_server/)
{
if ($key_order[$i] =~ /^$opt_server/)
{
unshift(@key_order,$key_order[$i]);
splice(@key_order,$i+1,1);
}
}
}
# extra for mysql and mysql_pgcc
#$number1 = shift(@key_order);
#$number2 = shift(@key_order);
#unshift(@key_order,$number1);
#unshift(@key_order,$number2);
# Print header
$column_count=0;
foreach $key (@key_order)
{
$column_count++;
# printf "%2d %-40.40s: %s %s\n", $column_count, $key,
# $tot{$key}{'server'}, $tot{$key}{'arguments'};
# print "Comments: $tot{$key}{'comments'}\n"
# if ($tot{$key}{'comments'} =~ /\w+/);
}
#print "\n";
$namewidth=$opt_skip_count ? 20 :25;
$colwidth= $opt_relative ? 9 : 6;
print_sep("=");
#printf "%-$namewidth.${namewidth}s|", "Operation";
$count = 1;
foreach $key (@key_order)
{
# printf "%${colwidth}d|", $count;
$count++;
}
#print "\n";
#print_sep("-");
#print_string("Results per test:");
#print_sep("-");
foreach $key (sort {$a cmp $b} keys %op1)
{
# printf "%-$namewidth.${namewidth}s|", $key;
$first=undef();
foreach $server (@key_order)
{
print_value($first,$tot{$server}{$key}->[0],$tot{$server}{$key}->[1]);
$first=$tot{$server}{$key}->[0] if (!defined($first));
}
# print "\n";
}
print_sep("-");
print_string("The results per operation:");
print_sep("-");
$luukcounter = 1;
foreach $key (sort {$a cmp $b} keys %op)
{
next if ($key =~ /TOTALS/i);
$tmp=$key;
$tmp.= " (" . $tot1{$key_order[0]}{$key}->[1] . ")" if (!$skip_count);
# printf "%-$namewidth.${namewidth}s|", $tmp;
$first=undef();
foreach $server (@key_order)
{
print_value($first,$tot1{$server}{$key}->[0],$tot1{$server}{$key}->[2]);
$first=$tot1{$server}{$key}->[0] if (!defined($first));
}
# print "\n";
$luukcounter++;
}
#print_sep("-");
$key="TOTALS";
#printf "%-$namewidth.${namewidth}s|", $key;
$first=undef();
foreach $server (@key_order)
{
# print_value($first,$tot1{$server}{$key}->[0],$tot1{$server}{$key}->[2]);
$first=$tot1{$server}{$key}->[0] if (!defined($first));
}
#print "\n";
#print_sep("=");
&make_gif;
exit 0;
#
# some format functions;
#
sub print_sep
{
my ($sep)=@_;
# print $sep x ($namewidth + (($colwidth+1) * $column_count)+1),"\n";
}
sub print_value
{
my ($first,$value,$flags)=@_;
my ($tmp);
if (defined($value))
{
if (!defined($first) || !$opt_relative)
{
$tmp=sprintf("%d",$value);
}
else
{
$first=1 if (!$first); # Assume that it took one second instead of 0
$tmp= sprintf("%.2f",$value/$first);
}
if (defined($flags))
{
$tmp="+".$tmp if ($flags =~ /\+/);
$tmp="?".$tmp if ($flags =~ /\?/);
}
}
else
{
$tmp="";
}
$tmp= " " x ($colwidth-length($tmp)) . $tmp if (length($tmp) < $colwidth);
# print $tmp . "|";
}
sub print_string
{
my ($str)=@_;
my ($width);
$width=$namewidth + ($colwidth+1)*$column_count;
$str=substr($str,1,$width) if (length($str) > $width);
# print($str," " x ($width - length($str)),"|\n");
}
sub usage
{
exit(0);
}
###########################################
###########################################
###########################################
# making here a gif of the results ... (lets try it :-))
# luuk .... 1997
###########################################
## take care that $highest / $giftotal / $gifcount / $luukcounter
## are getting there value above ... so don't forget them while
## copying the code to some other program ....
sub make_gif {
&gd; # some base things ....
&legend; # make the nice legend
&lines; # yep sometimes you have to print some lines
&gif("gif/benchmark2-".$opt_cmp); # and finally we can print all to a gif file ...
}
##### mmm we are finished now ...
# first we have to calculate some limits and some other stuff
sub calculate {
# here is the list which I have to know to make everything .....
# the small border width ... $sm_border =
# the border default $border =
# the step default ... if it must be calculated then no value $step =
# the highest number $highest =
# the max length of the text of the x borders $max_len_lb=
# the max length of a legend entry $max_len_le=
# number of entries in the legend $num_legen =
# the length of the color blocks for the legend $legend_block=
# the width of the gif ...if it must be calculated - no value $width =
# the height of the gif .. if it must be calculated - no value $height =
# the width of the grey field ' ' ' ' $width_grey=
# the height of the grey field ' ' ' ' $height_grey=
# number of dashed lines $lines=
# if bars must overlap how much they must be overlapped $overlap=
# titlebar title of graph in two colors big $titlebar=
# titlebar1 sub title of graph in small font in black $titlebar1=
# xlabel $xlabel=
# ylabel $ylabel=
# the name of the gif ... $name=
# then the following things must be knows .....
# xlabel below or on the left side ?
# legend yes/no?
# where must the legend be placed?
# must the xlabel be printed horizontal or vertical?
# must the ylabel be printed horizontal or vertical?
# must the graph be a line or a bar graph?
# is a xlabel several different entries or some sub entries of one?
# so xlabel 1 => test1=10, test2=15, test3=7 etc
# or xlabel 1 => test1a=12, test1b=10, test1c=7 etc
# must the bars overlap (only with the second example I think)
# must the number be printed above or next to the bar?
# when must the number be printed .... only when it extends the graph ...???
# the space between the bars .... are that the same width of the bars ...
# or is it a separate space ... defined ???
# must the date printed below or some where else ....
#calculate all space for text and other things ....
$sm_border = 8; # the grey border around ...
$border = 40; #default ...
$left_border = 2.75 * $border; #default ...
$right_border = $border; #default ...
$up_border = $border; #default ...
$down_border = $border; # default ...
$step = ($height - $up_border - $down_border)/ ($luukcounter + (($#key_order + 1) * $luukcounter));
# can set $step to get nice graphs ... and change the format ...
$step = 8; # set hard the step value
$gifavg = ($giftotal/$gifcount);
$highest = 2 * $gifavg;
$highest = 1; # set hard the highest value ...
$xhigh = int($highest + .5 * $highest);
# here to get the max lenght of the test entries ...
# so we can calculate the with of the left border
foreach $oper (sort keys (%op)) {
$max_len_lb = length($oper) if (length($oper) > $max_len_lb);
# print "oper = $oper - $max_len_lb\n";
}
$max_len_lb = $max_len_lb * gdSmallFont->width;
$left_border = (3*$sm_border) + $max_len_lb;
$down_border = (4*$sm_border) + (gdSmallFont->width*(length($xhigh)+3)) + (gdSmallFont->height *2);
$right_border = (3*$sm_border) + 3 + (gdSmallFont->width*(length($highest)+5));
# calculate the space for the legend .....
foreach $key (@key_order) {
$tmp = $key;
$tmp =~ s/-cmp-$opt_cmp//i;
$giflegend = sprintf "%-24.24s: %-40.40s",$tmp,$tot{$key}{'server'};
$max_len_le = length($giflegend) if (length($giflegend) > $max_len_le);
}
$max_len_le = $max_len_le * gdSmallFont->width;
$legend_block = 10; # the length of the block in the legend
$max_high_le = (($#key_order + 1)*(gdSmallFont->height+2)) + (2*$legend_block);
$down_border += $max_high_le;
$up_border = (5 * $sm_border) + gdSmallFont->height + gdLargeFont->height;
print "Here some things we already know ....\n";
# print "luukcounter = $luukcounter (number of tests)\n";
# print "gifcount = $gifcount (number of total entries)\n";
# print "giftotal = $giftotal (total secs)\n";
# print "gifavg = $gifavg\n";
# print "highest = $highest\n";
# print "xhigh = $xhigh\n";
# print "step = $step -- $#key_order\n";
# print "max_len_lb = $max_len_lb\n";
# printf "Small- width %d - height %s\n",gdSmallFont->width,gdSmallFont->height;
# printf "Tiny- width %d - height %s\n",gdTinyFont->width,gdTinyFont->height;
}
sub gd {
&calculate;
$width = 600; # the width ....
$height = 500; # the height ...
$width_greyfield = 430;
# when $step is set ... count the height ....????
$width = $width_greyfield + $left_border + $right_border;
$height = ($step * ($luukcounter + ($luukcounter * ($#key_order + 1)))) + $down_border + $up_border;
$b_width = $width - ($left_border + $right_border); # width within the grey field
$overlap = 0; # how far each colum can fall over each other ...nice :-)
# make the gif image ....
$im = new GD::Image($width,$height);
# allocate the colors to use ...
$white = $im->colorAllocate(255,255,255);
$black = $im->colorAllocate(0,0,0);
$paper_white = $im->colorAllocate(220, 220, 220);
$grey1 = $im->colorAllocate(240, 240, 240);
$grey4 = $im->colorAllocate(229, 229, 229);
$grey2 = $im->colorAllocate(102, 102, 102);
$grey3 = $im->colorAllocate(153, 153, 153);
$red = $im->colorAllocate(205,0,0); # msql
$lred = $im->colorAllocate(255,0,0);
$blue = $im->colorAllocate(0,0,205); # mysql
$lblue = $im->colorAllocate(0,0,255); # mysql_pgcc
$green = $im->colorAllocate(0, 205, 0); # postgres
$lgreen = $im->colorAllocate(0, 255, 0); # pg_fast
$orange = $im->colorAllocate(205,133, 0); # solid
$lorange = $im->colorAllocate(255, 165, 0); # Adabas
$yellow = $im->colorAllocate(205,205,0); # empress
$lyellow = $im->colorAllocate(255,255,0);
$magenta = $im->colorAllocate(255,0,255); # oracle
$lmagenta = $im->colorAllocate(255,200,255);
$cyan = $im->colorAllocate(0,205,205); # sybase
$lcyan = $im->colorAllocate(0,255,255);
$sienna = $im->colorAllocate(139,71,38); # db2
$lsienna = $im->colorAllocate(160,82,45);
$coral = $im->colorAllocate(205,91,69); # Informix
$lcoral = $im->colorAllocate(255,114,86);
$peach = $im->colorAllocate(205,175,149);
$lpeach = $im->colorAllocate(255,218,185);
@colors = ($red, $blue, $green, $orange, $yellow, $magenta, $cyan, $sienna, $coral, $peach);
@lcolors = ($lred, $lblue, $lgreen, $lorange, $lyellow, $lmagenta, $lcyan, $lsienna, $lcoral, $lpeach);
# set a color per server so in every result it has the same color ....
foreach $key (@key_order) {
if ($tot{$key}{'server'} =~ /mysql/i) {
if ($key =~ /mysql_pgcc/i || $key =~ /mysql_odbc/i || $key =~ /mysql_fast/i) {
$tot{$key}{'color'} = $lblue;
} else {
$tot{$key}{'color'} = $blue;
}
} elsif ($tot{$key}{'server'} =~ /msql/i) {
$tot{$key}{'color'} = $lred;
} elsif ($tot{$key}{'server'} =~ /postgres/i) {
if ($key =~ /pg_fast/i) {
$tot{$key}{'color'} = $lgreen;
} else {
$tot{$key}{'color'} = $green;
}
} elsif ($tot{$key}{'server'} =~ /solid/i) {
$tot{$key}{'color'} = $lorange;
} elsif ($tot{$key}{'server'} =~ /empress/i) {
$tot{$key}{'color'} = $lyellow;
} elsif ($tot{$key}{'server'} =~ /oracle/i) {
$tot{$key}{'color'} = $magenta;
} elsif ($tot{$key}{'server'} =~ /sybase/i) {
$tot{$key}{'color'} = $cyan;
} elsif ($tot{$key}{'server'} =~ /db2/i) {
$tot{$key}{'color'} = $sienna;
} elsif ($tot{$key}{'server'} =~ /informix/i) {
$tot{$key}{'color'} = $coral;
} elsif ($tot{$key}{'server'} =~ /microsoft/i) {
$tot{$key}{'color'} = $peach;
} elsif ($tot{$key}{'server'} =~ /access/i) {
$tot{$key}{'color'} = $lpeach;
} elsif ($tot{$key}{'server'} =~ /adabas/i) {
$tot{$key}{'color'} = $lorange;
}
}
# make the nice little borders
# left bar
$poly0 = new GD::Polygon;
$poly0->addPt(0,0);
$poly0->addPt($sm_border,$sm_border);
$poly0->addPt($sm_border,($height - $sm_border));
$poly0->addPt(0,$height);
$im->filledPolygon($poly0,$grey1);
$im->polygon($poly0, $grey4);
# upper bar
$poly3 = new GD::Polygon;
$poly3->addPt(0,0);
$poly3->addPt($sm_border,$sm_border);
$poly3->addPt(($width - $sm_border),$sm_border);
$poly3->addPt($width,0);
$im->polygon($poly3, $grey4);
$tmptime = localtime(time);
$im->string(gdSmallFont,($width - $sm_border - (gdSmallFont->width * length($tmptime))),($height - ($sm_border) - gdSmallFont->height), $tmptime, $grey3);
# right bar
$poly1 = new GD::Polygon;
$poly1->addPt($width,0);
$poly1->addPt(($width - $sm_border),$sm_border);
$poly1->addPt(($width - $sm_border),($height - $sm_border));
$poly1->addPt($width,$height);
$im->filledPolygon($poly1, $grey3);
$im->stringUp(gdSmallFont,($width - 10),($height - (2 * $sm_border)), "Made by Luuk de Boer - 1997 (c)", $blue);
#below bar
$poly2 = new GD::Polygon;
$poly2->addPt(0,$height);
$poly2->addPt($sm_border,($height - $sm_border));
$poly2->addPt(($width - $sm_border),($height - $sm_border));
$poly2->addPt($width,$height);
$im->filledPolygon($poly2, $grey2);
# do the black line around where in you will print ... (must be done at last
# but is hard to develop with ... but the filled grey must be done first :-)
$im->filledRectangle($left_border,$up_border,($width - ($right_border)),($height-$down_border),$grey4);
# print the nice title ...
$titlebar = "MySQL Benchmark results"; # head title ...
$titlebar1 = "Compare $opt_cmp "; # sub title
$header2 = "seconds/test"; # header value
$center = ($width / 2) - ((gdLargeFont->width * length($titlebar)) / 2);
$center1 = ($width / 2) - ((gdSmallFont->width * length($titlebar1)) / 2);
$center2 = ($width_greyfield/2) - ((gdSmallFont->width*length($header2))/2);
$bovenkant = $sm_border * 3;
$bovenkant1 = $bovenkant + gdLargeFont->height + (.5*$sm_border);
$bovenkant2 = $height - $down_border + (1*$sm_border) + (gdSmallFont->width*(length($xhigh)+3));
$im->string(gdLargeFont,($center),($bovenkant + 1), $titlebar, $grey3);
$im->string(gdLargeFont,($center),($bovenkant), $titlebar, $red);
$im->string(gdSmallFont,($center1),($bovenkant1), $titlebar1, $black);
$im->string(gdSmallFont,($left_border + $center2),($bovenkant2), $header2, $black);
$xlength = $width - $left_border - $right_border;
$lines = 10; # hard coded number of dashed lines
$xverh = $xlength / $xhigh;
# print " de verhouding ===> $xverh --- $xlength -- $xhigh \n";
$xstep = ($xhigh / $lines) * $xverh;
$teller = 0;
# make the nice dashed lines and print the values ...
for ($i = 0; $i <= $lines; $i++) {
$st2 = ($left_border) + ($i * $xstep);
$im->dashedLine($st2,($height-$down_border),$st2,($up_border), $grey3);
if (($i != 0) && ($teller == 2)) {
$st3 = sprintf("%.2f", $i*($xhigh/$lines));
$im->stringUp(gdTinyFont,($st2 - (gdSmallFont->height/2)),($height - $down_border +(.5*$sm_border) + (gdSmallFont->width*(length($xhigh)+3))), $st3, $black);
$teller = 0;
}
$teller++;
}
$im->rectangle($left_border,$up_border,($width - ($right_border)),($height-$down_border),$black);
}
sub legend {
# make the legend ...
$legxbegin = $left_border;
$legybegin = $height - $down_border + (2*$sm_border) + (gdSmallFont->width * (length($xhigh) + 3)) + gdSmallFont->height;
$legxend = $legxbegin + $max_len_le + (4*$legend_block);
$legxend = $legxbegin + $width_greyfield;
$legyend = $legybegin + $max_high_le;
$im->filledRectangle($legxbegin,$legybegin,$legxend,$legyend,$grey4);
$im->rectangle($legxbegin,$legybegin,$legxend,$legyend,$black);
# calculate the space for the legend .....
$c = 0; $i = 1;
$legybegin += $legend_block;
foreach $key (@key_order) {
$xtmp = $legxbegin + $legend_block;
$ytmp = $legybegin + ($c * (gdSmallFont->height +2));
$xtmp1 = $xtmp + $legend_block;
$ytmp1 = $ytmp + gdSmallFont->height;
$im->filledRectangle($xtmp,$ytmp,$xtmp1,$ytmp1,$tot{$key}{'color'});
$im->rectangle($xtmp,$ytmp,$xtmp1,$ytmp1,$black);
$tmp = $key;
$tmp =~ s/-cmp-$opt_cmp//i;
$giflegend = sprintf "%-24.24s: %-40.40s",$tmp,$tot{$key}{'server'};
$xtmp2 = $xtmp1 + $legend_block;
$im->string(gdSmallFont,$xtmp2,$ytmp,"$giflegend",$black);
$c++;
$i++;
# print "$c $i -> $giflegend\n";
}
}
sub lines {
$g = 0;
$i = 0;
$ybegin = $up_border + ((($#key_order + 2)/2)*$step);
$xbegin = $left_border;
foreach $key (sort {$a cmp $b} keys %op) {
next if ($key =~ /TOTALS/i);
$c = 0;
# print "key - $key\n";
foreach $server (@key_order) {
$tot1{$server}{$key}->[1] = 1 if ($tot1{$server}{$key}->[1] == 0);
$entry = $tot1{$server}{$key}->[0]/$tot1{$server}{$key}->[1];
$ytmp = $ybegin + ($i * $step) ;
$xtmp = $xbegin + ($entry * $xverh) ;
$ytmp1 = $ytmp + $step;
# print "$server -- $entry --x $xtmp -- y $ytmp - $c\n";
$entry1 = sprintf("%.2f", $entry);
if ($entry < $xhigh) {
$im->filledRectangle($xbegin, $ytmp, $xtmp, $ytmp1, $tot{$server}{'color'});
$im->rectangle($xbegin, $ytmp, $xtmp, $ytmp1, $black);
# print the seconds behind the bar (look below for another entry)
# this entry is for the bars that are not greater then the max width
# of the grey field ...
# $im->string(gdTinyFont,(($xtmp+3),($ytmp),"$entry1",$black));
# if you want the seconds in the color of the bar just uncomment it (below)
# $im->string(gdTinyFont,(($xtmp+3),($ytmp),"$entry1",$tot{$server}{'color'}));
} else {
$im->filledRectangle($xbegin, $ytmp, ($xbegin + ($xhigh*$xverh)), $ytmp1, $tot{$server}{'color'});
$im->rectangle($xbegin, $ytmp, ($xbegin + ($xhigh*$xverh)), $ytmp1, $black);
# print the seconds behind the bar (look below for another entry)
# here is the seconds printed behind the bar is the bar is too big for
# the graph ... (seconds is greater then xhigh ...)
$im->string(gdTinyFont, ($xbegin + ($xhigh*$xverh)+3),($ytmp),"$entry1",$black);
# if you want the seconds in the color of the bar just uncomment it (below)
# $im->string(gdTinyFont, ($xbegin + ($xhigh*$xverh)+3),($ytmp),"$entry1",$colors[$c]);
}
$c++;
$i++;
}
# see if we can center the text between the bars ...
$ytmp2 = $ytmp1 - (((($c)*$step) + gdSmallFont->height)/2);
$im->string(gdSmallFont,($sm_border*2),$ytmp2,$key, $black);
$i++;
}
}
sub gif {
my ($name) = @_;
$name_gif = $name . ".gif";
print "name --> $name_gif\n";
open (GIF, "> $name_gif") || die "Can't open $name_gif: $!\n";
print GIF $im->gif;
close (GIF);
}