[Zope3-Users] execution time of a request?

Marius Gedminas mgedmin at b4net.lt
Sat Apr 7 05:42:17 EDT 2007


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):
        try:
            start = time.time()
            return fn(*args, **kw)
        finally:
            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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20070407/442c25fa/attachment.bin


More information about the Zope3-users mailing list