Remove the recently-removed _scons_sets15.py from MANIFEST.in.
[scons.git] / bin / memoicmp.py
1 #!/usr/bin/env python
2 #
3 # A script to compare the --debug=memoizer output found in
4 # two different files.
5
6 import sys
7
8 def memoize_output(fname):
9     mout = {}
10     #lines=filter(lambda words:
11     #             len(words) == 5 and
12     #             words[1] == 'hits' and words[3] == 'misses',
13     #             map(string.split, open(fname,'r').readlines()))
14     #for line in lines:
15     #    mout[line[-1]] = ( int(line[0]), int(line[2]) )
16     for line in open(fname,'r').readlines():
17         words = line.split()
18         if len(words) == 5 and words[1] == 'hits' and words[3] == 'misses':
19             mout[words[-1]] = ( int(words[0]), int(words[2]) )
20     return mout
21
22 def memoize_cmp(filea, fileb):
23         ma = memoize_output(filea)
24         mb = memoize_output(fileb)
25
26         print 'All output: %s / %s [delta]'%(filea, fileb)
27         print '----------HITS---------- ---------MISSES---------'
28         cfmt='%7d/%-7d [%d]'
29         ma_o = []
30         mb_o = []
31         mab  = []
32         for k in ma.keys():
33                 if k in mb.keys():
34                         if k not in mab:
35                                 mab.append(k)
36                 else:
37                         ma_o.append(k)
38         for k in mb.keys():
39                 if k in ma.keys():
40                         if k not in mab:
41                                 mab.append(k)
42                 else:
43                         mb_o.append(k)
44
45         mab.sort()
46         ma_o.sort()
47         mb_o.sort()
48         
49         for k in mab:
50                 hits = cfmt%(ma[k][0], mb[k][0], mb[k][0]-ma[k][0])
51                 miss = cfmt%(ma[k][1], mb[k][1], mb[k][1]-ma[k][1])
52                 print '%-24s %-24s  %s'%(hits, miss, k)
53
54         for k in ma_o:
55                 hits = '%7d/ --'%(ma[k][0])
56                 miss = '%7d/ --'%(ma[k][1])
57                 print '%-24s %-24s  %s'%(hits, miss, k)
58
59         for k in mb_o:
60                 hits = '    -- /%-7d'%(mb[k][0])
61                 miss = '    -- /%-7d'%(mb[k][1])
62                 print '%-24s %-24s  %s'%(hits, miss, k)
63
64         print '-'*(24+24+1+20)
65         
66
67 if __name__ == "__main__":
68         if len(sys.argv) != 3:
69                 print """Usage: %s file1 file2
70
71 Compares --debug=memomize output from file1 against file2."""%sys.argv[0]
72                 sys.exit(1)
73
74         memoize_cmp(sys.argv[1], sys.argv[2])
75         sys.exit(0)
76
77 # Local Variables:
78 # tab-width:4
79 # indent-tabs-mode:nil
80 # End:
81 # vim: set expandtab tabstop=4 shiftwidth=4: