Anything you do in Python on the server will not tell you how long the user 
waited for the page to arrive at and be fully rendered in the browser -- it 
will only tell you how long web2py took to generate its response. If you 
want the full time from the original request leaving the browser until the 
page is fully rendered in the browser, you would have to use Javascript. 
See http://www.html5rocks.com/en/tutorials/webperformance/basics/.

As for your approach, the problem is that it won't represent the full 
amount of time web2py takes to generate a response, as it will miss some of 
the initial setup work web2py does before calling the first model, as well 
as the work it does after rendering the view. To get a more complete 
picture, you would probably have to implement some external middleware 
<http://web2py.com/books/default/chapter/29/04/the-core#External-middleware> 
that completely wraps the web2py request-response cycle. In any case, the 
time spent in web2py will probably only be a small part of the total time 
from page request to full page load.

Anthony

On Thursday, December 3, 2015 at 11:45:25 AM UTC-5, Richard wrote:
>
> Hello,
>
> Is web2py track page load time somehow, so I can just pick it up this 
> value and display page load time to end user?
>
> If not what could be a good way to monitor page load and display the page 
> load time in every view without degrading the performance too much?
>
> I think about this :
>
> # In models/db.py
> import time 
>
> loading_start = time.time()
> # in each controller or view
> loading_end = time.time()
>
> page_load_time = round(loading_end - loading_start, 3)
>
> Page load time : {{=page_load_time}}
>
>
> I found this too :
>
>
> http://stackoverflow.com/questions/17751163/django-display-time-it-took-to-load-a-page-on-every-page
>
> Thanks 
>
> Richard
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to