'Profile a singe call to the function.'

def __call__(self, *args, **kw):

    fn = self.fn
    self.ncalls += 1
    try:
        start = time.time()
        return fn(*args, **kw)
    finally:
        duration = (time.time() - start)
        self.totaltime += duration
        if self.immediate:
            funcname = fn.__name__
            filename = fn.func_code.co_filename
            lineno = fn.func_code.co_firstlineno
            print >>sys.stderr, ('\n        %s    (%s:%s):\n                %.3f    seconds\n' % (funcname, filename, lineno, duration))
