CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2004
    Location
    INDIA
    Posts
    24

    Question Difference of time in MilliSeconds - pls help urgent !!

    Hi friends,
    I am trying out a small function in which i want a time difference in milliseconds.
    but am not able to do it.

    i am using time_t tm;
    than doing GetLocalTime(&tm); and using another instance but time_t does not show time in milliseconds.

    I also tried with CTime and SYSTEMTIME but they give independant values and does not provide substraction facility.

    pls help ... how to do this ?

    Thanks.
    u Want and u get it - That is LUCK,
    u want and u wait - That is TIME,
    u want dut u compromise - That is LIFE,
    But U want, U wait and u Don't compromise, That is SUCCESS.

  2. #2

    Re: Difference of time in MilliSeconds - pls help urgent !!

    Aloha,

    you could use

    clock()

    Look in the MSDN, how to use it.
    Its really nice.

    Greetings

    BOA

  3. #3
    Join Date
    Apr 2004
    Posts
    17

    Re: Difference of time in MilliSeconds - pls help urgent !!

    hi,
    try the GetTickCount function.
    The difference between start of some code part and end would be the execution time in milliseconds.

    regards,
    typecast

  4. #4
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Difference of time in MilliSeconds - pls help urgent !!

    You should use QueryPerformanceCounter() or QueryPerformanceFrequency() in stead.

    If you try to benchmark a function, you dhould do something like this:
    Code:
    DWORD start, end;
    DWORD dwCounter = 10000; // or some other value
    
    QueryPerformanceCounter(&start);
    while(dwCounter--)
       foo(); // call your function
    QueryPerformanceCounter(&end);
    
    double average = (end-start)/10000;
    Last edited by cilu; September 27th, 2004 at 05:07 AM.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

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

Featured