From 0577bb82b876bd3f41f6b900ea0edc5a55f80d25 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Thu, 19 Feb 2009 11:41:23 +0100 Subject: [PATCH] First partial graph prototype using GD::Graph. --- perf/graph.pl | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 perf/graph.pl diff --git a/perf/graph.pl b/perf/graph.pl new file mode 100644 index 0000000..683f06d --- /dev/null +++ b/perf/graph.pl @@ -0,0 +1,84 @@ +#! /usr/bin/perl + +use strict; +use warnings; + +use GD::Graph::bars; +use GD::Graph::hbars; +use DBI; + + + + + + + +my ($host, $user, $pass)= @ARGV; + +my $dbh= DBI->connect("dbi:mysql:database=beedb;host=$host", $user, $pass, + { RaiseError => 1, PrintError => 0 }); + +my $sql= <prepare($sql); +$sth->execute(); +my $data= []; +my $idx_x; +my $idx_y= 0; +my ($last_instance, $last_counter); +my $variant_names= []; +while (my $r= $sth->fetchrow_arrayref()) +{ + my ($instance_idx, $counter_idx, $variant, $iterations, $workunits, $counter_name, $counter_value)= @$r; + if ($instance_idx == 0 && $counter_idx == 0) + { + push @$variant_names, $variant; + } + + if ((!defined($last_instance) || $last_instance != $instance_idx) || + (!defined($last_counter) || $last_counter != $counter_idx)) + { + if (!defined($last_instance)) + { + $idx_y= 0; + } + else + { + $idx_y++; + } + $idx_x= 1; + } + + $data->[$idx_x][$idx_y]= $counter_value; + $data->[0][$idx_y]= $counter_name if $idx_x == 1; + $last_instance= $instance_idx; + $last_counter= $counter_idx; + $idx_x++; +} + +use Data::Dumper; +# print Dumper($data); +# print Dumper($variant_names); + +my $graph= GD::Graph::hbars->new(1400, 800); +$graph->set( x_label => 'Test variant and counter name', + y_label => 'Counts', + title => 'bitcopy/bitcopy [bits=17; offs s=17 d=42]', + y_max_value => 10000000000, + bargroup_spacing => 4, + ); +$graph->set_legend(@$variant_names); +$graph->plot($data); + +binmode STDOUT; +my $ext= $graph->export_format(); +print $graph->gd->$ext(); -- 2.11.4.GIT