3 # Copyright (c) 2005 The SCons Foundation
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 filenames = sys.argv[1:]
29 if len(sys.argv) != 3:
30 print """Usage: objcounts.py file1 file2
32 Compare the --debug=object counts from two build logs.
36 def fetch_counts(fname):
37 contents = open(fname).read()
38 m = re.search('\nObject counts:\n(.*)\n[^\s]', contents, re.S)
39 lines = m.group().split('\n')
40 list = [l.split() for l in lines if re.match('\s+\d', l)]
43 d[l[-1]] = map(int, l[:-1])
46 c1 = fetch_counts(sys.argv[1])
47 c2 = fetch_counts(sys.argv[2])
52 common[k] = (c1[k], c2[k])
69 return " %5s/%-5s %-8s" % (c1, c2, d)
71 def printline(c1, c2, classname):
73 diffstr(c1[2], c2[2]) + \
74 diffstr(c1[3], c2[3]) + \
81 printline(c[0], c[1], k)
86 printline(c1[k], ['--']*4, k)
91 printline(['--']*4, c2[k], k)