summaryrefslogtreecommitdiffstats
path: root/3rdparty/openpgm-svn-r1135/pgm/gcov-parse.pl
blob: b87a3f3d09ac7646b34df05442bc244fd0767b74 (plain) (blame)
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
#!/usr/bin/perl

$type = '';
$target = '';

while (<>) {
	chomp;
	if (/^(Function|File) '(.+)'/) {
		$type = $1;
		$target = $2;
	} elsif (/^Lines executed:(\d+\.\d+)% of (\d+)/) {
#		print "$type,$target,$1,$2\n";
		if ($type cmp 'File') {
			$files{$target} = $1;
		} else {
			$functions{$target} = $1;
		}
	}
}

#@sorted = sort { $files{$a} <=> $files{$b} } keys %files;
#foreach $name (@sorted)
#{
#	print "$name:$files{$name}\n";
#}
@sorted = sort { $functions{$a} <=> $functions{$b} } keys %functions;
$total = 0;
$count = 0;
foreach $name (@sorted)
{
	next if $name =~ m#^/#;
	next if $name =~ m#.+\.h$#;
	next if $name =~ m#_unittest\.c$#;
	print sprintf("%20s: %3.1f%%\n", $name, $functions{$name});
	$total += $functions{$name};
	$count++;
}
$total /= $count;
print "\n               TOTAL: ~" . int($total) . "%\n\n";

# eof