![]() |
| | #1 |
| Registered User Join Date: Mar 2010
Posts: 3
| measuring accurate process time 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 | |
| | #2 |
| and the Hat of Guessing 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 | |
| | #3 | |
| Registered User Join Date: Mar 2010
Posts: 3
| Quote:
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 | |
| | #4 |
| and the Hat of Guessing 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 | |
| | #5 | |
| Registered User Join Date: Mar 2010
Posts: 3
| Quote:
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 | |
| | #6 |
| and the Hat of Guessing 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 | |
![]() |
| Thread Tools | |
| Display Modes | |
|
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 |