~ubuntu-branches/ubuntu/precise/ghc/precise

« back to all changes in this revision

Viewing changes to compiler/count_bytes

  • Committer: Bazaar Package Importer
  • Author(s): Joachim Breitner
  • Date: 2011-01-17 12:49:24 UTC
  • Revision ID: james.westby@ubuntu.com-20110117124924-do1pym1jlf5o636m
Tags: upstream-7.0.1
ImportĀ upstreamĀ versionĀ 7.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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;