|
-
Jan 7th, 2003, 04:24 AM
#1
Thread Starter
Lively Member
How to calculate duration of a process in seconds
Good day !
I have a problem here. I got a function call normalSearch to perform a linear search on an array. I wish to time the duration taken for the searching process. So I coded my program this way:
clock_t timeStart, timeEnd;
timeStart = clock();
searchResult = normalSearch(searchString, testArray);
timeEnd = clock();
timeUsed = (double)(timeEnd-timeStart)/CLK_TCK;
I thought it should return the timeUsed in the format of x.xx.
But weirdly enough, what I got is that, the timeStart is equal timeEnd ? That means the timeUsed is 0 ?
I have tried with 100000 elements but the result still the same.
How should I modify the function so that it can calculate the time correctly ?
Thanks a lot !
SonicWave
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|