|
-
Oct 17th, 2007, 02:36 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Track time asp.net page takes to load on client machine
How would I do something like this? Should I start a timer in the begginning of the "page load" function and a stop the timer at the end of the "page load" function.
I will be writing out a log file with information like....
user:bubba
searched:new cars
time for page load:10 seconds.
Basically, I will be flagging any searches that take a long time and checking to see what the user enters as a search criteria.
Should I also check how long it takes SQL to return the results? Is that even possible in asp.net?
This is for an asp.net project behind a SQL database. Any feedback or comments is greatly appreciated. Thanks.
-
Oct 17th, 2007, 03:17 PM
#2
Re: Track time asp.net page takes to load on client machine
I'd suggest starting the timer in Page.OnInit and end it in Page.OnUnload; this will be the time the page takes to execute - it won't include how long it takes to echo and render to the client.
And yes, if you're tracking which queries are causing delays, it's probably a good idea to measure how long the SQL queries take.
-
Oct 18th, 2007, 10:16 AM
#3
Re: Track time asp.net page takes to load on client machine
In your SQL stored procedure, declare two variables... @starttime and @endtime. Set them to CURRENT_TIMESTAMP at the beginning and end, obviously, then do a DATEDIFF() and return that along with your values, probably as an OUT parameter. That'll give you SQL Execution time.
-
Oct 24th, 2007, 10:58 AM
#4
Thread Starter
Addicted Member
Re: Track time asp.net page takes to load on client machine
vb Code:
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
TimeStats = New System.Timers.Timer 'create a new instance of the timer
TimeStats.Start()
End Sub
vb Code:
Private Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Unload
TimeStats.Stop()
End Sub
Okay, so what property do I access now to get the time? I usually, use a timer with an interval, but never to check for how long something took place.
-
Oct 24th, 2007, 02:35 PM
#5
Re: Track time asp.net page takes to load on client machine
Actually, a little easier than that:
Code:
DateTime start = DateTime.Now;
// ... Process
TimeSpan duration = DateTime.Now.Subtract(start);
-
Oct 24th, 2007, 06:34 PM
#6
Re: Track time asp.net page takes to load on client machine
It took 33.873 seconds to process this code.....
-
Oct 25th, 2007, 02:07 PM
#7
Re: Track time asp.net page takes to load on client machine
Ok
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|