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.
26 filenames
= sys
.argv
[1:]
28 if len(sys
.argv
) != 3:
29 print("""Usage: objcounts.py file1 file2
31 Compare the --debug=object counts from two build logs.
35 def fetch_counts(fname
):
36 contents
= open(fname
).read()
37 m
= re
.search('\nObject counts:(\n\s[^\n]*)*', contents
, re
.S
)
38 lines
= m
.group().split('\n')
39 list = [l
.split() for l
in lines
if re
.match('\s+\d', l
)]
42 d
[l
[-1]] = list(map(int, l
[:-1]))
45 c1
= fetch_counts(sys
.argv
[1])
46 c2
= fetch_counts(sys
.argv
[2])
49 for k
in list(c1
.keys()):
51 common
[k
] = (c1
[k
], c2
[k
])
53 # Transition: we added the module to the names of a bunch of
54 # the logged objects. Assume that c1 might be from an older log
55 # without the modules in the names, and look for an equivalent
60 for k2
in list(c2
.keys()):
62 common
[k2
] = (c1
[k
], c2
[k2
])
80 return " %5s/%-5s %-8s" % (c1
, c2
, d
)
82 def printline(c1
, c2
, classname
):
83 print(diffstr(c1
[2], c2
[2]) + \
84 diffstr(c1
[3], c2
[3]) + \
87 for k
in sorted(common
.keys()):
89 printline(c
[0], c
[1], k
)
91 for k
in sorted(list(c1
.keys())):
92 printline(c1
[k
], ['--']*4, k
)
94 for k
in sorted(list(c2
.keys())):
95 printline(['--']*4, c2
[k
], k
)
99 # indent-tabs-mode:nil
101 # vim: set expandtab tabstop=4 shiftwidth=4: