3 # A script to compare the --debug=memoizer output found in
8 def memoize_output(fname
):
10 #lines=filter(lambda words:
12 # words[1] == 'hits' and words[3] == 'misses',
13 # map(string.split, open(fname,'r').readlines()))
15 # mout[line[-1]] = ( int(line[0]), int(line[2]) )
16 for line
in open(fname
,'r').readlines():
18 if len(words
) == 5 and words
[1] == 'hits' and words
[3] == 'misses':
19 mout
[words
[-1]] = ( int(words
[0]), int(words
[2]) )
22 def memoize_cmp(filea
, fileb
):
23 ma
= memoize_output(filea
)
24 mb
= memoize_output(fileb
)
26 print('All output: %s / %s [delta]'%(filea
, fileb
))
27 print('----------HITS---------- ---------MISSES---------')
32 for k
in list(ma
.keys()):
33 if k
in list(mb
.keys()):
38 for k
in list(mb
.keys()):
39 if k
in list(ma
.keys()):
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
))
55 hits
= '%7d/ --'%(ma
[k
][0])
56 miss
= '%7d/ --'%(ma
[k
][1])
57 print('%-24s %-24s %s'%(hits
, miss
, k
))
60 hits
= ' -- /%-7d'%(mb
[k
][0])
61 miss
= ' -- /%-7d'%(mb
[k
][1])
62 print('%-24s %-24s %s'%(hits
, miss
, k
))
64 print('-'*(24+24+1+20))
67 if __name__
== "__main__":
68 if len(sys
.argv
) != 3:
69 print("""Usage: %s file1 file2
71 Compares --debug=memomize output from file1 against file2."""%sys
.argv
[0])
74 memoize_cmp(sys
.argv
[1], sys
.argv
[2])
79 # indent-tabs-mode:nil
81 # vim: set expandtab tabstop=4 shiftwidth=4: