Thread: measuring accurate process time

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    3

    measuring accurate process time

    hello

    i am a very begainer in c++

    i use borland c++ version 5

    i use the clock function to calculate the time spends of process: matrix multiplication of large size array

    the values are very high about 23000 ms and not reasonable

    i read that there is function measure the accurate process time called

    QueryPerformanceCounters()
    QueryPerformanceFrequency

    i tried two days to understand how to use it and add it to my code but and error occurs
    have any one of you used these two functions plz plz show me how to use what their header files and the type of parameters

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Well, 23 seconds seems reasonable to me, given what you say you are doing. Did the program not run for that long in real life?

    Everything I know about windows stuff I learned from MSDN, specifically here. What kind of errors are you getting?

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    3
    Quote Originally Posted by tabstop View Post
    Well, 23 seconds seems reasonable to me, given what you say you are doing. Did the program not run for that long in real life?

    Everything I know about windows stuff I learned from MSDN, specifically here. What kind of errors are you getting?
    Thanks alot for yr response , this is what i did in last two days

    LARGE_INTEGER frequency;
    LARGE_INTEGER begin1;
    LARGE_INTEGER end1;
    QueryPerformanceFrequency(&frequency);
    QueryPerformanceCounter(&begin1);

    for(int i = 0 ; i < size ; i++)
    for(int j = 0 ; j < size ; j++)
    for(int k = 0 ;k < size ; k++)
    C[i][k] += A[i][k]*B[k][j];



    QueryPerformanceCounter(&end1);

    LONGLONG elapsed = end.QuadPart - begin.QuadPart;


    the errors are:

    undefined symbol LARGE_INTEGER
    undefined symbol LONGLONG
    undefined symbol begain1
    undefined symbol end1
    Call to undefined function QueryPerformanceFrequency()
    Call to undefined function QueryPerformanceCounter()
    Last edited by i m sarah; 03-15-2010 at 09:42 AM.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Assuming you mean end1.QuadPart and begin1.QuadPart, that would give you the number of ticks (you would then have to divide by frequency to get seconds).

    If it were me, I would check the return value of your Queries, so that you are sure you have the hardware support necessary.

  5. #5
    Registered User
    Join Date
    Mar 2010
    Posts
    3
    Quote Originally Posted by tabstop View Post
    Assuming you mean end1.QuadPart and begin1.QuadPart, that would give you the number of ticks (you would then have to divide by frequency to get seconds).

    If it were me, I would check the return value of your Queries, so that you are sure you have the hardware support necessary.
    i modified to end1 and begain1 but still have the same problem undefined functions and symobls such LONGLONG and LARGE_INTEGER , how can check the return value of the queries without fixing the errors which prevent me from run the program
    i am asking too much but plz i need to use thes two functions , i checked help menu in c++ but it does not provide infor about it

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    If you look at the bottom of the MSDN page I linked to, it says what header you need to use; in this case, <windows.h>. And you need to check the return value -- they are BOOL functions, so they will return either TRUE or FALSE, and returning FALSE is bad. So
    Code:
    BOOL retval;
    retval = QueryPerformanceCounter(&begin1);
    if (retval == FALSE) {
        //do something about it
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. init adopts zombie process?
    By password636 in forum Linux Programming
    Replies: 4
    Last Post: 07-01-2009, 10:05 AM
  2. Replies: 6
    Last Post: 03-14-2009, 02:03 PM
  3. Determine process time in microseconds
    By kenkoh in forum C Programming
    Replies: 9
    Last Post: 02-18-2008, 02:16 PM
  4. When does a process not consume time
    By chasek92009 in forum C Programming
    Replies: 2
    Last Post: 10-21-2007, 07:34 PM
  5. Killing someones grandparents
    By nickname_changed in forum A Brief History of Cprogramming.com
    Replies: 37
    Last Post: 09-07-2003, 07:56 AM