C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 03-15-2010, 08:52 AM   #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
i m sarah is offline   Reply With Quote
Old 03-15-2010, 09:07 AM   #2
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 10,163
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?
tabstop is offline   Reply With Quote
Old 03-15-2010, 09:38 AM   #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.
i m sarah is offline   Reply With Quote
Old 03-15-2010, 09:43 AM   #4
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 10,163
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.
tabstop is offline   Reply With Quote
Old 03-15-2010, 09:52 AM   #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
i m sarah is offline   Reply With Quote
Old 03-15-2010, 09:56 AM   #6
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 10,163
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
}
tabstop is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
init adopts zombie process? password636 Linux Programming 4 07-01-2009 10:05 AM
How would i ensure only one copy of a process is running at a time NuNn C Programming 6 03-14-2009 02:03 PM
Determine process time in microseconds kenkoh C Programming 9 02-18-2008 02:16 PM
When does a process not consume time chasek92009 C Programming 2 10-21-2007 07:34 PM
Killing someones grandparents nickname_changed A Brief History of Cprogramming.com 37 09-07-2003 07:56 AM


All times are GMT -6. The time now is 12:10 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22