[ZODB-Dev] write performance

Neil Schemenauer nas@mems-exchange.org
Wed, 5 Feb 2003 16:27:49 -0500


On Wed, Feb 05, 2003 at 02:03:02PM -0500, Greg Ward wrote:
> Try profiling: hotshot works pretty well if you can dig up
> Fred's presentation from IPC10 (the only docs AFAIK).

Here's what I have in my PYTHONSTARTUP file:

def hotprofile(func, *args):
    import os, tempfile
    from hotshot import Profile, stats
    filename = tempfile.mktemp(".hotshot")
    p = Profile(filename)
    result = p.runcall(func, *args)
    p.close()
    s = stats.load(filename)
    s.strip_dirs().sort_stats("cumulative").print_stats()
    print
    s.strip_dirs().sort_stats("time").print_stats()
    os.unlink(filename)
    return result