Thank Anthony, for now it allow to display some stats if I want too, which
are pretty good... For further performance measure I can also just use the
profiler...

My main requirement was to be able to display end user some performance
stats...

Some improvement here (sorry BS 2.3) :

{{if auth.has_membership('admin'):}}
    <div class="row">
        <button class="btn btn-small"
onclick="$('#loading_stats').toggle();">Loading stats...</button>
        <br>
        <br>
        <div id="loading_stats" class="well span4" style="display: none;">
            <strong>Loading statistics</strong>
        </div>
    </div>

    <script type="text/javascript">
        function onLoad() {
            var now = new Date().getTime();
            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>Network latency: " + network_latency + " ms</p>"
).appendTo( "#loading_stats" );
            $( "<p>Loading page once everything is recieved from server: "
+ load_page_received + " ms</p>" ).appendTo( "#loading_stats" );
            $( "<p>Whole process of navigation and page load: " +
total_page_load + " ms</p>" ).appendTo( "#loading_stats" );
        }
    </script>
    {{pass}}

Forget to mention you have to put this in the layout :

<body {{if auth.has_membership('admin'):}}onload="onLoad()"{{pass}}>

Richard

On Fri, Dec 4, 2015 at 11:33 AM, Anthony <[email protected]> wrote:

> On Friday, December 4, 2015 at 9:38:57 AM UTC-5, Richard wrote:
>>
>> 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...
>>
>
> It won't make any difference whether this is in the layout or the view, as
> web2py delivers the entire HTML body together, and these calculations
> happen in the browser.
>
>
>> 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...
>>
>
> I think responseStart - requestStart would be the closest to approximating
> how long the server spends processing the request, though that number will
> also include the amount of time it takes to send the entire request as well
> as the time it takes for the initial part of the response to make it back
> to the browser. It will also include time the web server (e.g., nginx)
> spends processing before and after web2py does its work. If you want to
> know how long web2py spends, the most accurate approach would probably
> require adding some middleware.
>
> Anthony
>
> --
> 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.

Reply via email to