Skip to content

Commit

Permalink
print out histogram of freq each file was opened
Browse files Browse the repository at this point in the history
  • Loading branch information
zooko committed Jul 23, 2013
1 parent b301596 commit e26db96
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fdleakfinder/fdleakfinder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import copy, pprint, re, sys

from pyutil import dictutil

def main():
verbose = False
if ('-v' in sys.argv) or ('--verbose' in sys.argv):
Expand Down Expand Up @@ -80,6 +82,7 @@ def main():


openfiles = {} # k: fd, v: (fname, inl)
openedfiles = dictutil.NumDict() # k: fname, v: times opened

high_water_mark = None

Expand All @@ -98,6 +101,7 @@ def main():
raise
assert not openfiles.has_key(fd), (fd, fname, inl, openfiles[fd])
openfiles[fd] = (fname, inl)
openedfiles.inc(fname)

if verbose:
print "++ %d=>%s okay now there are %d, %s" % (fd, fname, len(openfiles), inl)
Expand Down Expand Up @@ -143,5 +147,8 @@ def main():
print "\n--- at the end: ", len(openfiles)
pprint.pprint(openfiles)

print "\n--- opened files: ", len(openedfiles)
pprint.pprint(openedfiles.items_sorted_by_value())

if __name__ == '__main__':
main()
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@
] },
test_suite=PKG+".test",
zip_safe=False, # I prefer unzipped for easier access.
install_requires=['pyutil'],
)

0 comments on commit e26db96

Please sign in to comment.