+ Reply to Thread
Results 1 to 3 of 3

Thread: How to calculate execution time of a procedure?

  1. #1

    How to calculate execution time of a procedure?

    Hi All,

    How to calculate execution time of a procedure?

    I want it to be in milliseconds precision.

    Help.

  2. #2
    Below code calculates the time of a procedure.

    Example:

    Code:
    void CallMe()
    {
    	for (int nIndex=0; nIndex<100; nIndex++)
    	{
    		Sleep(10) ;
    	}
    }
    
    void CalculateTime()
    {
        LARGE_INTEGER liFrequency ;
        QueryPerformanceFrequency(&liFrequency) ;
    
        liFrequency.QuadPart = liFrequency.QuadPart / 1000 ;
    
        LARGE_INTEGER liCounter1 ;
        QueryPerformanceCounter(&liCounter1) ;
    
        CallMe() ;
    
        LARGE_INTEGER liCounter2 ;
        QueryPerformanceCounter(&liCounter2) ;
    
        double dTotal = (liCounter2.QuadPart - liCounter1.QuadPart) / liFrequency.QuadPart ;
    }
    Hope this helps.

  3. #3
    Exactly, this is what I want.

    Thanks.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts