You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

660 lines
22 KiB

Fixed bug in mysqlcheck when using --fast Fixed problem when converting bigint to double. Fixed bug in count(distinct null) Fixed bug with empty BDB tables. BitKeeper/deleted/.del-ATIS-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~dd306b2e583ebde4: Delete: sql-bench/Results/ATIS-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg BitKeeper/deleted/.del-RUN-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~11038a44f73070e7: Delete: sql-bench/Results/RUN-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg BitKeeper/deleted/.del-alter-table-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~662b96bc66bc91b6: Delete: sql-bench/Results/alter-table-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg BitKeeper/deleted/.del-big-tables-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~788ad492867b1226: Delete: sql-bench/Results/big-tables-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg BitKeeper/deleted/.del-connect-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~5316add301edb60: Delete: sql-bench/Results/connect-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg BitKeeper/deleted/.del-create-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~26e09af61f88d8c9: Delete: sql-bench/Results/create-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg BitKeeper/deleted/.del-insert-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~fd2699adb3190d07: Delete: sql-bench/Results/insert-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg BitKeeper/deleted/.del-select-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~b01175ad38fd12b6: Delete: sql-bench/Results/select-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg BitKeeper/deleted/.del-wisconsin-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg~8ba598d217450157: Delete: sql-bench/Results/wisconsin-mysql-Linux_2.4.0_64GB_SMP_i686-cmp-mysql,pg Docs/manual.texi: Changelog + update to Linux section client/mysqlcheck.c: Fixed bug when using --fast --check --auto-repair --fast will not anymore repair tables that had warnings but where ok. mysql-test/r/bdb.result: New test case mysql-test/r/bigint.result: New test case mysql-test/r/count_distinct.result: New test case mysql-test/t/bdb.test: New test case mysql-test/t/bigint.test: New test case mysql-test/t/count_distinct.test: New test case sql-bench/Comments/postgres.benchmark: Update for PostgreSQL 7.1.2 sql-bench/graph-compare-results.sh: Fixed colors for mysql --fast tests sql/field.cc: Fixed problem when converting bigint to double. sql/item_sum.cc: Fixed bug in count(distinct null) sql/item_sum.h: Fixed bug in count(distinct null) sql/mysqlbinlog.cc: Fixed typo sql/sql_base.cc: cleanup sql/sql_select.cc: Fixed bug with empty BDB tables. sql/time.cc: Removed warning when reading timestamps with sub seconds.
25 years ago
  1. ####
  2. #### Hello ... this is a heavily hacked script by Luuk
  3. #### instead of printing the result it makes a nice gif
  4. #### when you want to look at the code ... beware of the
  5. #### ugliest code ever seen .... but it works ...
  6. #### and that's sometimes the only thing you want ... isn't it ...
  7. #### as the original script ... Hope you like it
  8. ####
  9. #### Greetz..... Luuk de Boer 1997.
  10. ####
  11. ## if you want the seconds behind the bar printed or not ...
  12. ## or only the one where the bar is too big for the graph ...
  13. ## look at line 535 of this program and below ...
  14. ## look in sub calculate for allmost all hard/soft settings :-)
  15. # a little program to generate a table of results
  16. # just read all the RUN-*.log files and format them nicely
  17. # Made by Luuk de Boer
  18. # Patched by Monty
  19. use Getopt::Long;
  20. use GD;
  21. $opt_server="mysql";
  22. $opt_cmp="mysql,pg,solid";
  23. $opt_cmp="msql,mysql,pg,solid";
  24. $opt_cmp="empress,mysql,pg,solid";
  25. $opt_dir="output";
  26. $opt_machine="";
  27. $opt_relative=$opt_same_server=$opt_help=$opt_Information=$opt_skip_count=0;
  28. GetOptions("Information","help","server=s","cmp=s","machine=s","relative","same-server","dir=s","skip-count") || usage();
  29. usage() if ($opt_help || $opt_Information);
  30. if ($opt_same_server)
  31. {
  32. $files="$opt_dir/RUN-$opt_server-*$opt_machine";
  33. }
  34. else
  35. {
  36. $files="$opt_dir/RUN-*$opt_machine";
  37. }
  38. $files.= "-cmp-$opt_cmp" if (length($opt_cmp));
  39. $automatic_files=0;
  40. if ($#ARGV == -1)
  41. {
  42. @ARGV=glob($files);
  43. $automatic_files=1;
  44. }
  45. #
  46. # Go trough all RUN files and gather statistics.
  47. #
  48. foreach (@ARGV)
  49. {
  50. $filename = $_;
  51. next if (defined($found{$_})); # remove duplicates
  52. $found{$_}=1;
  53. /RUN-(.*)$/;
  54. $prog = $1;
  55. push(@key_order,$prog);
  56. $next = 0;
  57. open(TMP, "<$filename") || die "Can't open $filename: $!\n";
  58. while (<TMP>)
  59. {
  60. chomp;
  61. if ($next == 0) {
  62. if (/Server version:\s+(\S+.*)/i)
  63. {
  64. $tot{$prog}{'server'} = $1;
  65. }
  66. elsif (/Arguments:\s+(.+)/i)
  67. {
  68. $tot{$prog}{'arguments'} = $1;
  69. # Remove some standard, not informative arguments
  70. $tot{$prog}{'arguments'} =~ s/--log|--use-old-results|--server=\S+|--cmp=\S+|--user=\S+|--pass=\S+|--machine=\S+//g;
  71. $tot{$prog}{'arguments'} =~ s/\s+/ /g;
  72. }
  73. elsif (/Comments:\s+(.+)/i) {
  74. $tot{$prog}{'comments'} = $1;
  75. } elsif (/^(\S+):\s*(estimated\s|)total\stime:\s+(\d+)\s+secs/i)
  76. {
  77. $tmp = $1; $tmp =~ s/://;
  78. $tot{$prog}{$tmp} = [ $3, (length($2) ? "+" : "")];
  79. $op1{$tmp} = $tmp;
  80. } elsif (/Totals per operation:/i) {
  81. $next = 1;
  82. next;
  83. }
  84. }
  85. elsif ($next == 1)
  86. {
  87. if (/^(\S+)\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\s*([+|?])*/)
  88. {
  89. $tot1{$prog}{$1} = [$2,$6,$7];
  90. $op{$1} = $1;
  91. #print "TEST - $_ \n * $prog - $1 - $2 - $6 - $7 ****\n";
  92. # $prog - filename
  93. # $1 - operation
  94. # $2 - time in secs
  95. # $6 - number of loops
  96. # $7 - nothing / + / ? / * => estimated time ...
  97. # get the highest value ....
  98. $highest = ($2/$6) if (($highest < ($2/$6)) && ($1 !~/TOTALS/i));
  99. $gifcount++;
  100. $giftotal += ($2/$6);
  101. }
  102. }
  103. }
  104. }
  105. if (!%op)
  106. {
  107. print "Didn't find any files matching: '$files'\n";
  108. print "Use the --cmp=server,server option to compare benchmarks\n";
  109. exit 1;
  110. }
  111. # everything is loaded ...
  112. # now we have to create a fancy output :-)
  113. # I prefer to redirect scripts instead to force it to file ; Monty
  114. #
  115. # open(RES, ">$resultfile") || die "Can't write to $resultfile: $!\n";
  116. # select(RES)
  117. #
  118. #print <<EOF;
  119. #<cut for this moment>
  120. #
  121. #EOF
  122. if ($opt_relative)
  123. {
  124. # print "Column 1 is in seconds. All other columns are presented relative\n";
  125. # print "to this. 1.00 is the same, bigger numbers indicates slower\n\n";
  126. }
  127. #print "The result logs which where found and the options:\n";
  128. if ($automatic_files)
  129. {
  130. if ($key_order[$i] =~ /^$opt_server/)
  131. {
  132. if ($key_order[$i] =~ /^$opt_server/)
  133. {
  134. unshift(@key_order,$key_order[$i]);
  135. splice(@key_order,$i+1,1);
  136. }
  137. }
  138. }
  139. # extra for mysql and mysql_pgcc
  140. #$number1 = shift(@key_order);
  141. #$number2 = shift(@key_order);
  142. #unshift(@key_order,$number1);
  143. #unshift(@key_order,$number2);
  144. # Print header
  145. $column_count=0;
  146. foreach $key (@key_order)
  147. {
  148. $column_count++;
  149. # printf "%2d %-40.40s: %s %s\n", $column_count, $key,
  150. # $tot{$key}{'server'}, $tot{$key}{'arguments'};
  151. # print "Comments: $tot{$key}{'comments'}\n"
  152. # if ($tot{$key}{'comments'} =~ /\w+/);
  153. }
  154. #print "\n";
  155. $namewidth=$opt_skip_count ? 20 :25;
  156. $colwidth= $opt_relative ? 9 : 6;
  157. print_sep("=");
  158. #printf "%-$namewidth.${namewidth}s|", "Operation";
  159. $count = 1;
  160. foreach $key (@key_order)
  161. {
  162. # printf "%${colwidth}d|", $count;
  163. $count++;
  164. }
  165. #print "\n";
  166. #print_sep("-");
  167. #print_string("Results per test:");
  168. #print_sep("-");
  169. foreach $key (sort {$a cmp $b} keys %op1)
  170. {
  171. # printf "%-$namewidth.${namewidth}s|", $key;
  172. $first=undef();
  173. foreach $server (@key_order)
  174. {
  175. print_value($first,$tot{$server}{$key}->[0],$tot{$server}{$key}->[1]);
  176. $first=$tot{$server}{$key}->[0] if (!defined($first));
  177. }
  178. # print "\n";
  179. }
  180. print_sep("-");
  181. print_string("The results per operation:");
  182. print_sep("-");
  183. $luukcounter = 1;
  184. foreach $key (sort {$a cmp $b} keys %op)
  185. {
  186. next if ($key =~ /TOTALS/i);
  187. $tmp=$key;
  188. $tmp.= " (" . $tot1{$key_order[0]}{$key}->[1] . ")" if (!$skip_count);
  189. # printf "%-$namewidth.${namewidth}s|", $tmp;
  190. $first=undef();
  191. foreach $server (@key_order)
  192. {
  193. print_value($first,$tot1{$server}{$key}->[0],$tot1{$server}{$key}->[2]);
  194. $first=$tot1{$server}{$key}->[0] if (!defined($first));
  195. }
  196. # print "\n";
  197. $luukcounter++;
  198. }
  199. #print_sep("-");
  200. $key="TOTALS";
  201. #printf "%-$namewidth.${namewidth}s|", $key;
  202. $first=undef();
  203. foreach $server (@key_order)
  204. {
  205. # print_value($first,$tot1{$server}{$key}->[0],$tot1{$server}{$key}->[2]);
  206. $first=$tot1{$server}{$key}->[0] if (!defined($first));
  207. }
  208. #print "\n";
  209. #print_sep("=");
  210. &make_gif;
  211. exit 0;
  212. #
  213. # some format functions;
  214. #
  215. sub print_sep
  216. {
  217. my ($sep)=@_;
  218. # print $sep x ($namewidth + (($colwidth+1) * $column_count)+1),"\n";
  219. }
  220. sub print_value
  221. {
  222. my ($first,$value,$flags)=@_;
  223. my ($tmp);
  224. if (defined($value))
  225. {
  226. if (!defined($first) || !$opt_relative)
  227. {
  228. $tmp=sprintf("%d",$value);
  229. }
  230. else
  231. {
  232. $first=1 if (!$first); # Assume that it took one second instead of 0
  233. $tmp= sprintf("%.2f",$value/$first);
  234. }
  235. if (defined($flags))
  236. {
  237. $tmp="+".$tmp if ($flags =~ /\+/);
  238. $tmp="?".$tmp if ($flags =~ /\?/);
  239. }
  240. }
  241. else
  242. {
  243. $tmp="";
  244. }
  245. $tmp= " " x ($colwidth-length($tmp)) . $tmp if (length($tmp) < $colwidth);
  246. # print $tmp . "|";
  247. }
  248. sub print_string
  249. {
  250. my ($str)=@_;
  251. my ($width);
  252. $width=$namewidth + ($colwidth+1)*$column_count;
  253. $str=substr($str,1,$width) if (length($str) > $width);
  254. # print($str," " x ($width - length($str)),"|\n");
  255. }
  256. sub usage
  257. {
  258. exit(0);
  259. }
  260. ###########################################
  261. ###########################################
  262. ###########################################
  263. # making here a gif of the results ... (lets try it :-))
  264. # luuk .... 1997
  265. ###########################################
  266. ## take care that $highest / $giftotal / $gifcount / $luukcounter
  267. ## are getting there value above ... so don't forget them while
  268. ## copying the code to some other program ....
  269. sub make_gif {
  270. &gd; # some base things ....
  271. &legend; # make the nice legend
  272. &lines; # yep sometimes you have to print some lines
  273. &gif("gif/benchmark2-".$opt_cmp); # and finally we can print all to a gif file ...
  274. }
  275. ##### mmm we are finished now ...
  276. # first we have to calculate some limits and some other stuff
  277. sub calculate {
  278. # here is the list which I have to know to make everything .....
  279. # the small border width ... $sm_border =
  280. # the border default $border =
  281. # the step default ... if it must be calculated then no value $step =
  282. # the highest number $highest =
  283. # the max length of the text of the x borders $max_len_lb=
  284. # the max length of a legend entry $max_len_le=
  285. # number of entries in the legend $num_legen =
  286. # the length of the color blocks for the legend $legend_block=
  287. # the width of the gif ...if it must be calculated - no value $width =
  288. # the height of the gif .. if it must be calculated - no value $height =
  289. # the width of the grey field ' ' ' ' $width_grey=
  290. # the height of the grey field ' ' ' ' $height_grey=
  291. # number of dashed lines $lines=
  292. # if bars must overlap how much they must be overlapped $overlap=
  293. # titlebar title of graph in two colors big $titlebar=
  294. # titlebar1 sub title of graph in small font in black $titlebar1=
  295. # xlabel $xlabel=
  296. # ylabel $ylabel=
  297. # the name of the gif ... $name=
  298. # then the following things must be knows .....
  299. # xlabel below or on the left side ?
  300. # legend yes/no?
  301. # where must the legend be placed?
  302. # must the xlabel be printed horizontal or vertical?
  303. # must the ylabel be printed horizontal or vertical?
  304. # must the graph be a line or a bar graph?
  305. # is a xlabel several different entries or some sub entries of one?
  306. # so xlabel 1 => test1=10, test2=15, test3=7 etc
  307. # or xlabel 1 => test1a=12, test1b=10, test1c=7 etc
  308. # must the bars overlap (only with the second example I think)
  309. # must the number be printed above or next to the bar?
  310. # when must the number be printed .... only when it extends the graph ...???
  311. # the space between the bars .... are that the same width of the bars ...
  312. # or is it a separate space ... defined ???
  313. # must the date printed below or some where else ....
  314. #calculate all space for text and other things ....
  315. $sm_border = 8; # the grey border around ...
  316. $border = 40; #default ...
  317. $left_border = 2.75 * $border; #default ...
  318. $right_border = $border; #default ...
  319. $up_border = $border; #default ...
  320. $down_border = $border; # default ...
  321. $step = ($height - $up_border - $down_border)/ ($luukcounter + (($#key_order + 1) * $luukcounter));
  322. # can set $step to get nice graphs ... and change the format ...
  323. $step = 8; # set hard the step value
  324. $gifavg = ($giftotal/$gifcount);
  325. $highest = 2 * $gifavg;
  326. $highest = 1; # set hard the highest value ...
  327. $xhigh = int($highest + .5 * $highest);
  328. # here to get the max lenght of the test entries ...
  329. # so we can calculate the with of the left border
  330. foreach $oper (sort keys (%op)) {
  331. $max_len_lb = length($oper) if (length($oper) > $max_len_lb);
  332. # print "oper = $oper - $max_len_lb\n";
  333. }
  334. $max_len_lb = $max_len_lb * gdSmallFont->width;
  335. $left_border = (3*$sm_border) + $max_len_lb;
  336. $down_border = (4*$sm_border) + (gdSmallFont->width*(length($xhigh)+3)) + (gdSmallFont->height *2);
  337. $right_border = (3*$sm_border) + 3 + (gdSmallFont->width*(length($highest)+5));
  338. # calculate the space for the legend .....
  339. foreach $key (@key_order) {
  340. $tmp = $key;
  341. $tmp =~ s/-cmp-$opt_cmp//i;
  342. $giflegend = sprintf "%-24.24s: %-40.40s",$tmp,$tot{$key}{'server'};
  343. $max_len_le = length($giflegend) if (length($giflegend) > $max_len_le);
  344. }
  345. $max_len_le = $max_len_le * gdSmallFont->width;
  346. $legend_block = 10; # the length of the block in the legend
  347. $max_high_le = (($#key_order + 1)*(gdSmallFont->height+2)) + (2*$legend_block);
  348. $down_border += $max_high_le;
  349. $up_border = (5 * $sm_border) + gdSmallFont->height + gdLargeFont->height;
  350. print "Here some things we already know ....\n";
  351. # print "luukcounter = $luukcounter (number of tests)\n";
  352. # print "gifcount = $gifcount (number of total entries)\n";
  353. # print "giftotal = $giftotal (total secs)\n";
  354. # print "gifavg = $gifavg\n";
  355. # print "highest = $highest\n";
  356. # print "xhigh = $xhigh\n";
  357. # print "step = $step -- $#key_order\n";
  358. # print "max_len_lb = $max_len_lb\n";
  359. # printf "Small- width %d - height %s\n",gdSmallFont->width,gdSmallFont->height;
  360. # printf "Tiny- width %d - height %s\n",gdTinyFont->width,gdTinyFont->height;
  361. }
  362. sub gd {
  363. &calculate;
  364. $width = 600; # the width ....
  365. $height = 500; # the height ...
  366. $width_greyfield = 430;
  367. # when $step is set ... count the height ....????
  368. $width = $width_greyfield + $left_border + $right_border;
  369. $height = ($step * ($luukcounter + ($luukcounter * ($#key_order + 1)))) + $down_border + $up_border;
  370. $b_width = $width - ($left_border + $right_border); # width within the grey field
  371. $overlap = 0; # how far each colum can fall over each other ...nice :-)
  372. # make the gif image ....
  373. $im = new GD::Image($width,$height);
  374. # allocate the colors to use ...
  375. $white = $im->colorAllocate(255,255,255);
  376. $black = $im->colorAllocate(0,0,0);
  377. $paper_white = $im->colorAllocate(220, 220, 220);
  378. $grey1 = $im->colorAllocate(240, 240, 240);
  379. $grey4 = $im->colorAllocate(229, 229, 229);
  380. $grey2 = $im->colorAllocate(102, 102, 102);
  381. $grey3 = $im->colorAllocate(153, 153, 153);
  382. $red = $im->colorAllocate(205,0,0); # msql
  383. $lred = $im->colorAllocate(255,0,0);
  384. $blue = $im->colorAllocate(0,0,205); # mysql
  385. $lblue = $im->colorAllocate(0,0,255); # mysql_pgcc
  386. $green = $im->colorAllocate(0, 205, 0); # postgres
  387. $lgreen = $im->colorAllocate(0, 255, 0); # pg_fast
  388. $orange = $im->colorAllocate(205,133, 0); # solid
  389. $lorange = $im->colorAllocate(255, 165, 0); # Adabas
  390. $yellow = $im->colorAllocate(205,205,0); # empress
  391. $lyellow = $im->colorAllocate(255,255,0);
  392. $magenta = $im->colorAllocate(255,0,255); # oracle
  393. $lmagenta = $im->colorAllocate(255,200,255);
  394. $cyan = $im->colorAllocate(0,205,205); # sybase
  395. $lcyan = $im->colorAllocate(0,255,255);
  396. $sienna = $im->colorAllocate(139,71,38); # db2
  397. $lsienna = $im->colorAllocate(160,82,45);
  398. $coral = $im->colorAllocate(205,91,69); # Informix
  399. $lcoral = $im->colorAllocate(255,114,86);
  400. $peach = $im->colorAllocate(205,175,149);
  401. $lpeach = $im->colorAllocate(255,218,185);
  402. @colors = ($red, $blue, $green, $orange, $yellow, $magenta, $cyan, $sienna, $coral, $peach);
  403. @lcolors = ($lred, $lblue, $lgreen, $lorange, $lyellow, $lmagenta, $lcyan, $lsienna, $lcoral, $lpeach);
  404. # set a color per server so in every result it has the same color ....
  405. foreach $key (@key_order) {
  406. if ($tot{$key}{'server'} =~ /mysql/i) {
  407. if ($key =~ /mysql_pgcc/i || $key =~ /mysql_odbc/i || $key =~ /mysql_fast/i) {
  408. $tot{$key}{'color'} = $lblue;
  409. } else {
  410. $tot{$key}{'color'} = $blue;
  411. }
  412. } elsif ($tot{$key}{'server'} =~ /msql/i) {
  413. $tot{$key}{'color'} = $lred;
  414. } elsif ($tot{$key}{'server'} =~ /postgres/i) {
  415. if ($key =~ /pg_fast/i) {
  416. $tot{$key}{'color'} = $lgreen;
  417. } else {
  418. $tot{$key}{'color'} = $green;
  419. }
  420. } elsif ($tot{$key}{'server'} =~ /solid/i) {
  421. $tot{$key}{'color'} = $lorange;
  422. } elsif ($tot{$key}{'server'} =~ /empress/i) {
  423. $tot{$key}{'color'} = $lyellow;
  424. } elsif ($tot{$key}{'server'} =~ /oracle/i) {
  425. $tot{$key}{'color'} = $magenta;
  426. } elsif ($tot{$key}{'server'} =~ /sybase/i) {
  427. $tot{$key}{'color'} = $cyan;
  428. } elsif ($tot{$key}{'server'} =~ /db2/i) {
  429. $tot{$key}{'color'} = $sienna;
  430. } elsif ($tot{$key}{'server'} =~ /informix/i) {
  431. $tot{$key}{'color'} = $coral;
  432. } elsif ($tot{$key}{'server'} =~ /microsoft/i) {
  433. $tot{$key}{'color'} = $peach;
  434. } elsif ($tot{$key}{'server'} =~ /access/i) {
  435. $tot{$key}{'color'} = $lpeach;
  436. } elsif ($tot{$key}{'server'} =~ /adabas/i) {
  437. $tot{$key}{'color'} = $lorange;
  438. }
  439. }
  440. # make the nice little borders
  441. # left bar
  442. $poly0 = new GD::Polygon;
  443. $poly0->addPt(0,0);
  444. $poly0->addPt($sm_border,$sm_border);
  445. $poly0->addPt($sm_border,($height - $sm_border));
  446. $poly0->addPt(0,$height);
  447. $im->filledPolygon($poly0,$grey1);
  448. $im->polygon($poly0, $grey4);
  449. # upper bar
  450. $poly3 = new GD::Polygon;
  451. $poly3->addPt(0,0);
  452. $poly3->addPt($sm_border,$sm_border);
  453. $poly3->addPt(($width - $sm_border),$sm_border);
  454. $poly3->addPt($width,0);
  455. $im->polygon($poly3, $grey4);
  456. $tmptime = localtime(time);
  457. $im->string(gdSmallFont,($width - $sm_border - (gdSmallFont->width * length($tmptime))),($height - ($sm_border) - gdSmallFont->height), $tmptime, $grey3);
  458. # right bar
  459. $poly1 = new GD::Polygon;
  460. $poly1->addPt($width,0);
  461. $poly1->addPt(($width - $sm_border),$sm_border);
  462. $poly1->addPt(($width - $sm_border),($height - $sm_border));
  463. $poly1->addPt($width,$height);
  464. $im->filledPolygon($poly1, $grey3);
  465. $im->stringUp(gdSmallFont,($width - 10),($height - (2 * $sm_border)), "Made by Luuk de Boer - 1997 (c)", $blue);
  466. #below bar
  467. $poly2 = new GD::Polygon;
  468. $poly2->addPt(0,$height);
  469. $poly2->addPt($sm_border,($height - $sm_border));
  470. $poly2->addPt(($width - $sm_border),($height - $sm_border));
  471. $poly2->addPt($width,$height);
  472. $im->filledPolygon($poly2, $grey2);
  473. # do the black line around where in you will print ... (must be done at last
  474. # but is hard to develop with ... but the filled grey must be done first :-)
  475. $im->filledRectangle($left_border,$up_border,($width - ($right_border)),($height-$down_border),$grey4);
  476. # print the nice title ...
  477. $titlebar = "MySQL Benchmark results"; # head title ...
  478. $titlebar1 = "Compare $opt_cmp "; # sub title
  479. $header2 = "seconds/test"; # header value
  480. $center = ($width / 2) - ((gdLargeFont->width * length($titlebar)) / 2);
  481. $center1 = ($width / 2) - ((gdSmallFont->width * length($titlebar1)) / 2);
  482. $center2 = ($width_greyfield/2) - ((gdSmallFont->width*length($header2))/2);
  483. $bovenkant = $sm_border * 3;
  484. $bovenkant1 = $bovenkant + gdLargeFont->height + (.5*$sm_border);
  485. $bovenkant2 = $height - $down_border + (1*$sm_border) + (gdSmallFont->width*(length($xhigh)+3));
  486. $im->string(gdLargeFont,($center),($bovenkant + 1), $titlebar, $grey3);
  487. $im->string(gdLargeFont,($center),($bovenkant), $titlebar, $red);
  488. $im->string(gdSmallFont,($center1),($bovenkant1), $titlebar1, $black);
  489. $im->string(gdSmallFont,($left_border + $center2),($bovenkant2), $header2, $black);
  490. $xlength = $width - $left_border - $right_border;
  491. $lines = 10; # hard coded number of dashed lines
  492. $xverh = $xlength / $xhigh;
  493. # print " de verhouding ===> $xverh --- $xlength -- $xhigh \n";
  494. $xstep = ($xhigh / $lines) * $xverh;
  495. $teller = 0;
  496. # make the nice dashed lines and print the values ...
  497. for ($i = 0; $i <= $lines; $i++) {
  498. $st2 = ($left_border) + ($i * $xstep);
  499. $im->dashedLine($st2,($height-$down_border),$st2,($up_border), $grey3);
  500. if (($i != 0) && ($teller == 2)) {
  501. $st3 = sprintf("%.2f", $i*($xhigh/$lines));
  502. $im->stringUp(gdTinyFont,($st2 - (gdSmallFont->height/2)),($height - $down_border +(.5*$sm_border) + (gdSmallFont->width*(length($xhigh)+3))), $st3, $black);
  503. $teller = 0;
  504. }
  505. $teller++;
  506. }
  507. $im->rectangle($left_border,$up_border,($width - ($right_border)),($height-$down_border),$black);
  508. }
  509. sub legend {
  510. # make the legend ...
  511. $legxbegin = $left_border;
  512. $legybegin = $height - $down_border + (2*$sm_border) + (gdSmallFont->width * (length($xhigh) + 3)) + gdSmallFont->height;
  513. $legxend = $legxbegin + $max_len_le + (4*$legend_block);
  514. $legxend = $legxbegin + $width_greyfield;
  515. $legyend = $legybegin + $max_high_le;
  516. $im->filledRectangle($legxbegin,$legybegin,$legxend,$legyend,$grey4);
  517. $im->rectangle($legxbegin,$legybegin,$legxend,$legyend,$black);
  518. # calculate the space for the legend .....
  519. $c = 0; $i = 1;
  520. $legybegin += $legend_block;
  521. foreach $key (@key_order) {
  522. $xtmp = $legxbegin + $legend_block;
  523. $ytmp = $legybegin + ($c * (gdSmallFont->height +2));
  524. $xtmp1 = $xtmp + $legend_block;
  525. $ytmp1 = $ytmp + gdSmallFont->height;
  526. $im->filledRectangle($xtmp,$ytmp,$xtmp1,$ytmp1,$tot{$key}{'color'});
  527. $im->rectangle($xtmp,$ytmp,$xtmp1,$ytmp1,$black);
  528. $tmp = $key;
  529. $tmp =~ s/-cmp-$opt_cmp//i;
  530. $giflegend = sprintf "%-24.24s: %-40.40s",$tmp,$tot{$key}{'server'};
  531. $xtmp2 = $xtmp1 + $legend_block;
  532. $im->string(gdSmallFont,$xtmp2,$ytmp,"$giflegend",$black);
  533. $c++;
  534. $i++;
  535. # print "$c $i -> $giflegend\n";
  536. }
  537. }
  538. sub lines {
  539. $g = 0;
  540. $i = 0;
  541. $ybegin = $up_border + ((($#key_order + 2)/2)*$step);
  542. $xbegin = $left_border;
  543. foreach $key (sort {$a cmp $b} keys %op) {
  544. next if ($key =~ /TOTALS/i);
  545. $c = 0;
  546. # print "key - $key\n";
  547. foreach $server (@key_order) {
  548. $tot1{$server}{$key}->[1] = 1 if ($tot1{$server}{$key}->[1] == 0);
  549. $entry = $tot1{$server}{$key}->[0]/$tot1{$server}{$key}->[1];
  550. $ytmp = $ybegin + ($i * $step) ;
  551. $xtmp = $xbegin + ($entry * $xverh) ;
  552. $ytmp1 = $ytmp + $step;
  553. # print "$server -- $entry --x $xtmp -- y $ytmp - $c\n";
  554. $entry1 = sprintf("%.2f", $entry);
  555. if ($entry < $xhigh) {
  556. $im->filledRectangle($xbegin, $ytmp, $xtmp, $ytmp1, $tot{$server}{'color'});
  557. $im->rectangle($xbegin, $ytmp, $xtmp, $ytmp1, $black);
  558. # print the seconds behind the bar (look below for another entry)
  559. # this entry is for the bars that are not greater then the max width
  560. # of the grey field ...
  561. # $im->string(gdTinyFont,(($xtmp+3),($ytmp),"$entry1",$black));
  562. # if you want the seconds in the color of the bar just uncomment it (below)
  563. # $im->string(gdTinyFont,(($xtmp+3),($ytmp),"$entry1",$tot{$server}{'color'}));
  564. } else {
  565. $im->filledRectangle($xbegin, $ytmp, ($xbegin + ($xhigh*$xverh)), $ytmp1, $tot{$server}{'color'});
  566. $im->rectangle($xbegin, $ytmp, ($xbegin + ($xhigh*$xverh)), $ytmp1, $black);
  567. # print the seconds behind the bar (look below for another entry)
  568. # here is the seconds printed behind the bar is the bar is too big for
  569. # the graph ... (seconds is greater then xhigh ...)
  570. $im->string(gdTinyFont, ($xbegin + ($xhigh*$xverh)+3),($ytmp),"$entry1",$black);
  571. # if you want the seconds in the color of the bar just uncomment it (below)
  572. # $im->string(gdTinyFont, ($xbegin + ($xhigh*$xverh)+3),($ytmp),"$entry1",$colors[$c]);
  573. }
  574. $c++;
  575. $i++;
  576. }
  577. # see if we can center the text between the bars ...
  578. $ytmp2 = $ytmp1 - (((($c)*$step) + gdSmallFont->height)/2);
  579. $im->string(gdSmallFont,($sm_border*2),$ytmp2,$key, $black);
  580. $i++;
  581. }
  582. }
  583. sub gif {
  584. my ($name) = @_;
  585. $name_gif = $name . ".gif";
  586. print "name --> $name_gif\n";
  587. open (GIF, "> $name_gif") || die "Can't open $name_gif: $!\n";
  588. print GIF $im->gif;
  589. close (GIF);
  590. }