report-thesis.pl from CQual at Krugle
Show report-thesis.pl syntax highlighted
#!/usr/bin/perl
# Sub-directories with data
$p = "parseonly";
$fis = "fis";
$fs = "fs";
$dependencies_file = "collected_dependencies";
if ($#ARGV == -1) {
printf("Usage: report-thesis.pl <dirs>\n");
exit(0);
}
open(DEPS, $dependencies_file);
@deps = <DEPS>;
print_header();
foreach $dep (@deps) {
chomp($dep);
if ($dep =~ /:/) {
($head, $rest) = split(/:/, $dep);
$rest =~ s/^\s+//gm;
@ifiles = split(/\s+/, $rest);
split / +/, `wc @ifiles | tail -n 1`; # last line is total
$lines = @_[1];
@pinfo = (0, 0, 0, 0);
@fisinfo = (0, 0, 0, 0);
@fsinfo = (0, 0, 0, 0);
foreach $exp (@ARGV) {
@npinfo = getinfo("$exp/$p/$head.out");
@nfisinfo = getinfo("$exp/$fis/$head.out");
@nfsinfo = getinfo("$exp/$fs/$head.out");
for ($i = 0; $i <= $#pinfo; $i++) {
$pinfo[$i] += $npinfo[$i];
$fisinfo[$i] += $nfisinfo[$i];
$fsinfo[$i] += $nfsinfo[$i];
}
}
for ($i = 0; $i <= $#pinfo; $i++) {
$pinfo[$i] /= ($#ARGV + 1);
$fisinfo[$i] /= ($#ARGV + 1);
$fsinfo[$i] /= ($#ARGV + 1);
}
print_info("$head.out", $lines, @pinfo, @fisinfo, @fsinfo);
}
}
# Extract analysis summary from file
sub getinfo
{
my $funcs, $errs, $time, $vmsize, $filename, $finished;
$filename = shift;
$funcs = 0;
$errs = 0;
$time = "???";
$finished = 0;
open(FILE, "<$filename");
while (<FILE>) {
if (/^Assuming/) { $funcs++; }
elsif (/inconsistent/) { $errs++; }
elsif (/^Elapsed time/) { ($time) = m/^Elapsed time: (.*)s/; }
elsif (/^VMSize/) { ($vmsize) = m/^VMSize: (.*)K/; }
elsif (/^Analysis complete/) { $finished = 1; }
}
if ($finished) {
return ($funcs, $errs, $time, $vmsize);
}
else {
return (-1, -1, -1, -1);
}
}
# Remove $n levels of directories from the left of name
sub shiftdirs
{
my $n, $name, @path, $i;
($n, $name) = @_;
@path = split(/\//, $name);
for ($i = 0; $i < $n; $i++) {
shift(@path);
}
$name = join("/", @path);
return $name;
}
# Printing routines
sub print_header
{
printf("File Lines Flow-Sensitive Flow-Insensitive Parsing Flow-Sensitive Flow-Insensitive Parsing\n");
}
sub print_info
{
my $name, $lines, $ptime, $psize, $fistime, $fissize, $fstime, $fssize;
($name,
$lines,
($_, $_, $ptime, $psize),
($_, $_, $fistime, $fissize),
($_, $_, $fstime, $fssize)) = @_;
printf "$name $lines $fstime $fistime $ptime $fssize $fissize $psize\n";
}
See more files for this project here