14 # Find a good max value that is a nice round number and not too far
15 # from given max data value.
18 $value= -$value if $value < 0;
19 $value= 1 if $value == 0;
20 my $base= 10**POSIX
::floor
(log($value)/log(10));
23 my $candidate= $_*$base;
24 return $candidate if $candidate >= $value;
26 # Shouldn't really be possible to get here...
31 my ($host, $user, $pass)= @ARGV;
33 my $dbh= DBI
->connect("dbi:mysql:database=beedb;host=$host", $user, $pass,
34 { RaiseError
=> 1, PrintError
=> 0 });
37 SELECT instance_idx, counter_idx, variant, iterations, workunits, counter_name, counter_value
39 INNER JOIN perf_counts ON (perf_test_run.id = perf_counts.test_run_id)
40 WHERE perf_test_run.suite_run_id = 17
41 AND test_major = 'bitcopy'
42 AND test_minor = 'bitcopy'
43 AND param1 = 'bits=17'
44 AND param2 = 'offs s=17 d=42'
45 ORDER BY counter_name, instance_idx, counter_idx, variant
47 my $sth= $dbh->prepare($sql);
52 my ($last_instance, $last_counter);
53 my $variant_names= [];
55 my ($instance_idx, $counter_idx, $variant, $iterations, $workunits, $counter_name, $counter_value);
57 while (my $r= $sth->fetchrow_arrayref())
59 ($instance_idx, $counter_idx, $variant, $iterations, $workunits, $counter_name, $counter_value)= @
$r;
60 if ($instance_idx == 0 && $counter_idx == 0)
62 push @
$variant_names, $variant;
65 if ((!defined($last_instance) || $last_instance != $instance_idx) ||
66 (!defined($last_counter) || $last_counter != $counter_idx))
68 if (!defined($last_instance))
79 $iterations= 1 unless $iterations;
80 $workunits= 1 unless $workunits;
81 my $value= $counter_value / $iterations / $workunits;
82 $max_y= $value unless defined($max_y) && $max_y >= $value;
83 $data->[$idx_x][$idx_y]= $value;
84 $data->[0][$idx_y]= $counter_name if $idx_x == 1;
85 $last_instance= $instance_idx;
86 $last_counter= $counter_idx;
91 # print Dumper($data);
92 # print Dumper($variant_names);
94 my $graph= GD
::Graph
::hbars
->new(1400, 800);
95 $graph->set( x_label
=> "Counter name",
96 y_label
=> "Counts per iteration(I) per workunit(U)",
97 title
=> "bitcopy/bitcopy [bits=17; offs s=17 d=42] I=$iterations U=$workunits",
98 y_max_value
=> calc_good_max
($max_y),
99 bargroup_spacing
=> 4,
101 $graph->set_legend(@
$variant_names);
105 my $ext= $graph->export_format();
106 print $graph->gd->$ext();