[Zodb-checkins] CVS: StandaloneZODB/bsddb3Storage/bsddb3Storage - profout.py:1.1.2.1

Barry Warsaw barry@wooz.org
Wed, 17 Apr 2002 16:23:47 -0400


Update of /cvs-repository/StandaloneZODB/bsddb3Storage/bsddb3Storage
In directory cvs.zope.org:/tmp/cvs-serv20641/bsddb3Storage

Added Files:
      Tag: bsddb3Storage-picklelog-branch
	profout.py 
Log Message:
A script that reads line event data out of a hotshot profile file and
prints a sorted list of times spent per line (in order from least to
most amount of time).


=== Added File StandaloneZODB/bsddb3Storage/bsddb3Storage/profout.py ===
import os
import pprint
from hotshot.log import LogReader

prevloc = None
byline = {}
log = LogReader('profile.dat')

for what, place, tdelta in log:
    byline[prevloc] = tdelta + byline.get(prevloc, 0)
    byline.setdefault(place,0)
    prevloc = place

# Sort
results = [(v, k) for k, v in byline.items()]
results.sort()

for usecs, place in results:
    if not place:
        print 'Bad unpack:', usecs, place
        continue
    filename, line, funcname = place
    print '%08d' % usecs, os.path.split(filename)[1], line