Results 1 to 7 of 7

Thread: [RESOLVED] Track time asp.net page takes to load on client machine

  1. #1

    Thread Starter
    Addicted Member silentthread's Avatar
    Join Date
    Jun 2006
    Location
    Miami, Florida
    Posts
    143

    Resolved [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.

    Watch media as you download it! Excellent tool!
    FREE CUBA!
    MyBlog
    If you feel my post has helped, please rate it.

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    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.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  4. #4

    Thread Starter
    Addicted Member silentthread's Avatar
    Join Date
    Jun 2006
    Location
    Miami, Florida
    Posts
    143

    Re: Track time asp.net page takes to load on client machine

    vb Code:
    1. Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
    2.         'CODEGEN: This method call is required by the Web Form Designer
    3.         'Do not modify it using the code editor.
    4.         InitializeComponent()
    5.         TimeStats = New System.Timers.Timer 'create a new instance of the timer
    6.         TimeStats.Start()
    7.     End Sub



    vb Code:
    1. Private Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Unload
    2.  
    3.         TimeStats.Stop()
    4.  
    5.     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.
    Watch media as you download it! Excellent tool!
    FREE CUBA!
    MyBlog
    If you feel my post has helped, please rate it.

  5. #5
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    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);

  6. #6
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: Track time asp.net page takes to load on client machine

    It took 33.873 seconds to process this code.....

  7. #7
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    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
  •  



Click Here to Expand Forum to Full Width