-
Notifications
You must be signed in to change notification settings - Fork 10
/
bugfix-frequency.pl
81 lines (62 loc) · 1.79 KB
/
bugfix-frequency.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
#!/usr/bin/perl
# NOTE: uses the curl-www repo for input!
my $webroot = $ARGV[0] || "../curl-www";
$csv = "$webroot/docs/releases.csv";
my %release;
my @inorder;
my $p;
sub buginfo {
open(C, "<$csv");
while(<C>) {
chomp;
my ($index, $version, $vulns, $date, $since, $ddays, $adays, $dbugs, $abugs,
$dchanges, $achanges) = split(';', $_);
$release{$version}=$date;
$dfixes{$version}=$dbugs; # fixed in this release
$afixes{$version}=$abugs; # fixed since the latest release, including this
$age{$version}=$adays; # days since latest release
$dage{$version}=$ddays; # days since latest release
push @inorder, $version;
$p = $date; # remmeber the last date, which is the earliest
}
close(C);
}
buginfo();
sub days {
my ($prev, $date) = @_;
my $psecs = `date +%s -d "$prev"`;
my $secs = `date +%s -d "$date"`;
return int(($secs-$psecs)/86400);
}
# compare this many releases back
my $delta = 5;
my $addup = 0;
my $firstrel = $inorder[ $#inorder ];
my @sorder = reverse @inorder;
sub sum {
my @p = @_;
my $sum;
for my $y (@p) {
$sum += $y;
}
return $sum;
}
for my $i (0 .. $#sorder) {
my $r = $sorder[$i];
my $compare = $i;
$addup += $dfixes{$r};
push @dv, $dfixes{$r};
push @da, $release{$r};
# keep the array less than one year
while(days($da[0], $release{$r}) > 365) {
shift @dv;
shift @da;
}
# get the age range
my $age = days($da[0], $release{$r});
# bugfixes within the range
my $bugs = sum(@dv);
my $bugsperday = $bugs / ($age ? $age : 1);
#print "bugs: $bugs ($afixes{$compver} - $afixes{$r}) / age: $age ($compver vs $r)\n";
printf "%s;%d;%.3f\n", $release{$r}, $addup, $bugsperday;
}