What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 7881 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > ASP.NET > calculate the time taken by a web page to execute ...
Ddd

calculate the time taken by a web page to execute

 Code Snippet posted by: Ddd | Posted on: 1/31/2011 | Category: ASP.NET Codes | Views: 1914 | Status: [Member] | Points: 40 | Alert Moderator   


//Write this coding in the Global.asax file

//when you run .aspx page, you can see the execution time in millseconds.


 void Application_BeginRequest(object sender, EventArgs e)

{
Context.Items.Add("startime", DateTime.Now);
}
void Application_EndRequest(object sender, EventArgs e)
{
//Get the start time
DateTime dt=(DateTime)Context.Items["startime"];
//calculate the time difference between start and end of request
TimeSpan ts = DateTime.Now-dt;
Response.Write("number of milleseconds for execution"+"--"+ts.TotalMilliseconds);


}


dinesh k.
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/26/2013 4:46:24 AM