App Engine - exit response time

Say I wanted to print the response time on my pages, like Google.

How can I do it?

+4
source share
1 answer

Call start = time.time() as the very first operation in your processing scripts, and when you just finished with everything, time.time() - start as the last version (correctly formatted version) you are using.

If you use templates for your output (for example, the Django templates that come with the application engine are 0.96 by default, although you can explicitly request newer and better ones ;-) or jinja2, mako, ...), it’s important be able to use a tag or filter in these templates to query and format such an expression. (You don’t want to calculate it at the time you invoke the template renderer method and pass it as part of this method context, otherwise you won’t be able to take into account all the time the template was rendered in your evaluation of the “response time” -!). You may need to encode and enter such tag or filter in the "template language" if the selected language and version of the templates are not yet supplied, but at least minimally extensible ;-).

`

+3
source

All Articles