开发者

How to calculate load time of Asp.net page using Jquery/Javascript?

开发者 https://www.devze.com 2023-04-06 21:03 出处:网络
I am developing one web application in that I want to check load time of each and every page or controls load time..

I am developing one web application in that I want to check load time of each and every page or controls load time..

How much time taken to load whole page contents?

I want to calculate asp.net page load 开发者_StackOverflowTime in Micro second/Second,

How can I know using Javascript/Jquery ?


Following script help you;

<SCRIPT LANGUAGE="JavaScript">
//calculate the time before calling the function in window.onload
beforeload = (new Date()).getTime();
function pageloadingtime()
{

     //calculate the current time in afterload 
    afterload = (new Date()).getTime();
     // now use the beforeload and afterload to calculate the seconds
    secondes = (afterload-beforeload)/1000;
     // If necessary update in window.status
    window.status='You Page Load took  ' + secondes + ' seconde(s).';
     // Place the seconds in the innerHTML to show the results
    document.getElementById("loadingtime").innerHTML = "<font color='red'>(You Page Load took " + secondes + " seconde(s).)</font>";

}

window.onload = pageloadingtime;
</SCRIPT>

Ref from : http://www.dreamincode.net/code/snippet1908.htm

or

If you just want to check the time make use of Firebug of firefox which display excution time. Something like this

How to calculate load time of Asp.net page using Jquery/Javascript?


Developed by the good people at stackoverflow - handy little profiling tool - may work for you:

http://code.google.com/p/mvc-mini-profiler/

0

精彩评论

暂无评论...
验证码 换一张
取 消