Simon's hacking on monad-comp; incomplete
[ghc-hetmet.git] / compiler / count_bytes
1 #! /usr/local/bin/perl
2 #
3 %DirCount = ();
4 %ModCount = ();
5
6 foreach $f ( @ARGV ) {
7     die "Not an .lhs file: $f\n" if $f !~ /\.lhs$/;
8     $f =~ s/\.lhs$/.o/;
9
10     $f_size = `size $f`;
11     die "Size failed?\n" if $? != 0;
12
13     if ( $f_size =~ /(\S+)\s*(\S+)\s*(\S+)\s*(\d+)\s*(\S+)/ ) {
14         $totsz = $4;
15
16         if ( $f =~ /(.*)\/(.*)/ ) {
17             local($dir) = $1;
18             local($mod) = $2;
19             $DirCount{$dir} += $totsz;
20             $ModCount{$mod} += $totsz;
21         } else {
22             print STDERR "not counted in a directory: $f\n";
23             $ModCount{$f} += $totsz;
24         }
25     } else {
26         die "Can't figure out size: $f_size\n";
27     }
28 }
29
30 # print the info
31 $tot = 0;
32 foreach $d (sort (keys %DirCount)) {
33     printf "%-20s %6d\n", $d, $DirCount{$d};
34     $tot += $DirCount{$d};
35 }
36 printf "\n%-20s %6d\n\n\n", 'TOTAL:', $tot;
37
38 $tot = 0;
39 foreach $m (sort (keys %ModCount)) {
40     printf "%-20s %6d\n", $m, $ModCount{$m};
41     $tot += $ModCount{$m};
42 }
43 printf "\n%-20s %6d\n", 'TOTAL:', $tot;