Here what I crafted so far :
<div id="timing"></div>
<script type="text/javascript">
function onLoad() {
var now = new Date().getTime();
var page_load_time = now - performance.timing.navigationStart;
var network_latency = performance.timing.responseEnd -
performance.timing.fetchStart
var load_page_received = now - performance.timing.responseEnd
var total_page_load = now - performance.timing.navigationStart
$( "<p>User-perceived page loading time: " + page_load_time + "
ms</p>" ).appendTo( "#timing" );
$( "<p>Network latency: " + network_latency + " ms</p>"
).appendTo( "#timing" );
$( "<p>Loading page once everything is recieved from server: "
+ load_page_received + " ms</p>" ).appendTo( "#timing" );
$( "<p>Whole process of navigation and page load: " +
total_page_load + " ms</p>" ).appendTo( "#timing" );
}
</script>
I think this need to be in each view, because if we put it in layout it
doesn't consider the remaining treatment associate to the controller and
the view...
I am not sure about Network latency in case of web2py... To me it is more a
measure of web2py rapidity since it is associate to the time the request
take to complete and the broswer recieve the full html content from
web2py... I think it include network latency, but it mostly a measure of
app performance to me...
Richard
On Thu, Dec 3, 2015 at 2:11 PM, Richard Vézina <[email protected]>
wrote:
> First link pretty interresting... Now I need a howto... :)
>
> Richard
>
> On Thu, Dec 3, 2015 at 1:51 PM, Anthony <[email protected]> wrote:
>
>> 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.
>>
>
>
--
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.