display time it took to execute store procedure

Last post 03-04-2009 10:37 PM by broadys. 4 replies.

Sort Posts:

  • display time it took to execute store procedure

    10-26-2008, 10:40 AM
    • Member
      128 point Member
    • lindows
    • Member since 04-27-2008, 4:29 AM
    • Posts 280

    hi there,

    would anyone know how to spit out the time it took for a page to run a store procedure from mysql???

    basically this is for troubleshooting, so when a page loads and bind data to gridsview, formview..etc...

    i want to have couple of labels somewhere on the page to display how long did it took the page to load and the store procedure to run

    hope someone has sample they could share

    cheers

  • Re: display time it took to execute store procedure

    10-26-2008, 11:11 AM
    Answer
    • All-Star
      89,167 point All-Star
    • SGWellens
    • Member since 01-02-2007, 9:27 PM
    • Twin Cities, MN
    • Posts 7,278
    • Moderator
      TrustedFriends-MVPs

    You can time most things like this:

     

        protected void Button1_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Stopwatch Timer = new Stopwatch();
    
            Timer.Start();
    
            // do the task
            Thread.Sleep(1000);
    
            Timer.Stop();
    
            Label1.Text = Timer.Elapsed.TotalSeconds.ToString("N2");
    
     
    Steve Wellens

    My blog
  • Re: display time it took to execute store procedure

    10-26-2008, 11:43 PM
    • Member
      128 point Member
    • lindows
    • Member since 04-27-2008, 4:29 AM
    • Posts 280

     what is "N2"?

      Label1.Text = Timer.Elapsed.TotalSeconds.ToString("N2");
    
      
  • Re: display time it took to execute store procedure

    10-27-2008, 9:56 AM
    Answer
    • All-Star
      89,167 point All-Star
    • SGWellens
    • Member since 01-02-2007, 9:27 PM
    • Twin Cities, MN
    • Posts 7,278
    • Moderator
      TrustedFriends-MVPs

    TotalSeconds is type Double (a floating point type).

    N2 formats the number to two decimal places:

    1   :   1.00

    2.3  :  2.30

    1.234 : 1.23

    Steve Wellens

    My blog
  • Re: display time it took to execute store procedure

    03-04-2009, 10:37 PM
    • Member
      9 point Member
    • broadys
    • Member since 06-09-2003, 5:08 PM
    • Australia
    • Posts 13

    Thanks Steve for explaining about "TotalSeconds N2". It took me all day to find out how to round "TotalSeconds" to 2 decimal places.

    Your explanation is short and to the point, thanks...

    Filed under: ,
Page 1 of 1 (5 items)