On Fri, Apr 06, 2007 at 11:15:47PM +0200, Maciej Wisniowski wrote:
> > does anyone know a method to get or compute the execution time of a
> > request?
> Lori - plugin for firefox, or firebug etc?
> Or do you want to display this on page?

Firebug doesn't quite cut it: it only displays time spent downloading,
not the time spent waiting until Zope processes the request.

I usually wrap my view's __call__ in a @timecall decorator like this:

def timecall(fn):
    def new_fn(*args, **kw):
            start = time.time()
            return fn(*args, **kw)
            duration = time.time() - start
            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)
    new_fn.__doc__ = fn.__doc__
    return new_fn

Marius Gedminas
Veni, Vidi, VISA:  I came, I saw, I did a little shopping.

Attachment: signature.asc
Description: Digital signature

Zope3-users mailing list

Reply via email to