-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchart.pl
executable file
·117 lines (104 loc) · 3.04 KB
/
chart.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/perl
use strict;
use warnings;
use IO::File;
use Data::Dumper;
use Chart::Gnuplot;
my $from = $ARGV[0];
my $to = $ARGV[1];
die "bad arguments\n " unless($from =~ m/\d{1,10}$/ and $to =~ m/\d{1,10}$/);
my $fh = IO::File->new("./stats", 'r');
my $res = {};
my %clients;
my $tot_events = 0;
my $max_time = 0;
while(my $line = $fh->getline()) {
chomp( $line );
my @cols = split(/,/, $line );
my $rec = {};
for my $c (@cols) {
my @elem = split(/=/, $c);
next unless($elem[0]);
if($elem[0] eq "tot_events") {
$tot_events = $elem[1];
}
if($elem[0] eq "clients") {
$clients{$elem[0]}->{cc}++;
}
$rec->{$elem[0]} = $elem[1];
}
if($rec->{clients} >= $from and $rec->{clients} <= $to) {
my $l = $rec->{lib};
my $f = $rec->{files};
my $cc = $rec->{clients};
$max_time = $rec->{tot_time} if($rec->{tot_time} > $max_time);
$res->{$l}->{$cc}->{$f}->{count}++;
$res->{$l}->{$cc}->{$f}->{files} += $rec->{files};
$res->{$l}->{$cc}->{$f}->{clients} += $rec->{clients};
$res->{$l}->{$cc}->{$f}->{tot_time} += $rec->{tot_time};
}
}
print "$max_time\n";
#warn Dumper($res);
my $chart = Chart::Gnuplot->new(
output => "./graphs/benchmark-$from-$to-clients-libev-libevent.png",
title => {
text => "Benchmark libev against Libevent",
font => 'Helvetica, 26',
},
xlabel => "File Descriptor Count",
ylabel => "Time (secs)",
xrange => [0, 300000],
yrange => [0, $max_time + 0.1],
size => "1.5, 1.4",
imagesize => "1.2, 1.2",
tmargin => 4,
bmargin => 2,
rmargin => 35,
legend => {
position => "outside right",
width => 3,
height => 5,
align => "left",
order => "vertical",
title => "Legend",
sample => {
length => 5,
position => "left",
spacing => 2,
},
border => {
linetype => 1,
width => 2,
color => "blue",
},
},
grid => {
type => 'dash',
width => 1,
},
);
my $header = {};
my @graphs;
for my $lib ( keys %{$res} ) {
for my $cc ( sort { $a <=> $b } keys %{$res->{$lib}}) {
next unless ($cc >= $from and $cc <= $to);
$header->{$cc} = {'title' => "$cc $lib Clients",
'style' => 'lines',
'width' => 5,
};
my @table;
for my $fc ( sort { $a <=> $b } keys %{$res->{$lib}->{$cc}} ) {
my $tmp = $res->{$lib}->{$cc}->{$fc};
#push(@table, [$fc, $tmp->{tot_time}/$tmp->{count}]);
push(@{ $header->{$cc}->{xdata} }, $fc);
push(@{ $header->{$cc}->{ydata} }, $tmp->{tot_time}/$tmp->{count});
}
}
for my $cc (sort {$a <=> $b} keys %{ $header } ) {
my $g = $header->{$cc};
my $obj = Chart::Gnuplot::DataSet->new(%{ $g });
push(@graphs, $obj);
}
}
$chart->plot2d(@graphs);