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