Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 72 lines (54 sloc) 1.775 kB
0f17b94 @rcaputo An Imager::Plot based graphing program for making sense of
authored
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use Imager;
7 use Imager::Color;
8 use Imager::Plot;
9
10 open(DATA, "<benchmark.out") or die $!;
11
12 my $lo_index = ~0;
13 my $hi_index = 0;
14
15 my %raw_data;
16
17 while (<DATA>) {
18 chomp;
19 my ($index, $queue, $function, $time) = split /\t/;
20
21 $lo_index = $index if $lo_index < $index;
22 $hi_index = $index if $index > $hi_index;
23
24 $raw_data{$function}->{$queue}->[$index] = $time;
25 }
26
27 my %colors = (Array => "red", PriorityHeap => "blue");
28 my $colors = join("; ", map { "$_=$colors{$_}" } sort(keys %colors));
29
30 foreach my $magnitude ($hi_index) {
31 my @x = $lo_index .. $magnitude-1;
32
33 foreach my $function (keys %raw_data) {
34
35 my $plot = Imager::Plot->new
36 ( Width => 1024-40,
37 Height => 768-80,
38 GlobalFont => 'gara.ttf'
39 );
40
2d40523 @rcaputo Scale times in microseconds.
authored
41 my $axis = $plot->GetAxis();
42 $axis->{Yformat} = sub { sprintf("%.0f", $_[0]*1000000) };
43
44 $plot->{Ylabel} = 'time per operation (microseconds)';
0f17b94 @rcaputo An Imager::Plot based graphing program for making sense of
authored
45 $plot->{Xlabel} = 'queue priorities';
46 $plot->{Title} = "Benchmark for `$function' ($colors)";
47
48 foreach my $queue (keys %{$raw_data{$function}}) {
49 my @y = @{$raw_data{$function}{$queue}};
50 $plot->AddDataSet( X => \@x,
51 Y => \@y,
52 style => { line=> { color => $colors{$queue} } },
53 );
54 }
55
56 my $img = Imager->new( xsize => 1024,
57 ysize => 768,
58 );
59 $img->box( filled => 1,
60 color => 'white'
61 );
62 $plot->Render( Image => $img,
63 Xoff => 40/2,
64 Yoff => (768-80/2),
65 );
66
67 my $filename = "$function-$magnitude.png";
68 $filename =~ tr[ ][_];
69 $img->write(file => $filename);
70 }
71 }
Something went wrong with that request. Please try again.