Results 1 to 5 of 5

Thread: Elapse time

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    416

    Elapse time

    Hi,

    I'm doing a performance test on calling a function in different situation. I record the start and end time to a DateTime variable, and calculate the no. of seconds elapsed using Datediff function.

    However, I found that it only accurate to seconds, if the different is less than 1, it will became 0. How can I measure the time in more accurate way?

    Thx!

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: Elapse time

    Quote Originally Posted by stm
    Hi,

    I'm doing a performance test on calling a function in different situation. I record the start and end time to a DateTime variable, and calculate the no. of seconds elapsed using Datediff function.

    However, I found that it only accurate to seconds, if the different is less than 1, it will became 0. How can I measure the time in more accurate way?

    Thx!
    hmm how are you using DateTime as a counter? show me I wanna know
    I think the correct way to do this is to use performance counters. I dont really know how to do this with .NET but I think you can use these apis
    QueryPerformanceFrequency
    QueryPerformanceCounter


    umm anyways I did this in C# with the TimeSpan object and it works fine, gives the miliseconds too. Try using it...

    a = new TimeSpan(DateTime.Now.Ticks);
    b = new TimeSpan(DateTime.Now.Ticks);

    b= b.Subtract(a);
    MessageBox.Show (b.Seconds.ToString() + " " + b.Milliseconds.ToString());
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    416

    Re: Elapse time

    HoHo...Don't laugh me.

    I just record the current time using Now, and Datediff.........

  4. #4
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: Elapse time

    Quote Originally Posted by stm
    HoHo...Don't laugh me.

    I just record the current time using Now, and Datediff.........
    oh got you... I wasnt laughing at you haha
    umm and THAT didn't give you the milliseconds?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    416

    Re: Elapse time

    yes and it helps.......thx a lot!

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