Calculating Search Times

Ok, I'm going crazy!

   I have a basic program to make.  It is suppose to calculate the average time it takes to do a search.  
My code looks like this:

//sequential search function
        //x = search value
     clock_t start, end;
     start = clock();
     for (i =0; i<n && CurrentArray[i] !=x; i++)
     {
          if (i==n)
               exit (.1);     //ERROR! x not found!
     }    
     end = clock();
     return end-start;

I preform this search about numerous times, with randomly chosen x values .
ok so the problem I have is that no matter how large my array is, the return time is ALWAYS zero, IF I allow the function to run on it's on.  However if I debug it, executing the code line by line I am able to get none zero times.  
PLEASE HELP!!!!
I have already recieved a 60 for this project, but have midterms soon!
wdrake_98Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kent OlsenData Warehouse Architect / DBACommented:
The problem is: Your search is too fast.


It's completing before the system clock timer ticks to the next interval.

Try doing 1000 or 100,000 searches for the same item between checks of the clock and compute the search time from that.


kdo
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wdrake_98Author Commented:
Very FAST response!!!!
I just may have to sign up for the premium service!
It worked... had to increase it to like 1000, searches between the clocks but it worked...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.