Results 1 to 2 of 2

Thread: How to calculate duration of a process in seconds

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Posts
    101

    Question 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

  2. #2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width