Topic: clock_t and the clock() function


Author: ying@nps.navy.mil (Stephen J. Ying)
Date: 23 Aug 1994 00:55:09 GMT
Raw View
I'm trying to time my quicksort program by using the clock_t ADT as follows:

    float tps = 1e6;  //Using 1e6 ticks per sec as a guess

    clock_t start,end,ticksPerSecond = int(tps);

   start=clock();                  //start clock
   tempFile.quickSort(numLines);   //sort the lines
   end=clock();                    //stop clock

   cout << "\nSort time in seconds at " << ticksPerSecond;
   cout << " ticks per second = " << ((end-start)/tps) << endl;

The problem is that it returns the time in ticks and I need to convert into
seconds.  The Clocks_Per_Sec macro is not in the header libraries on my system.
I'm on a Sparc10.  Anyone know what I can do?


---
||||||||||||||||||||||||||||||||||||||
||                                  ||
|| Stephen J Ying                   ||
||                                  ||
|| Internet DNS: ying@nps.navy.mil ||
||                                  ||
||||||||||||||||||||||||||||||||||||||






Author: ying@nps.navy.mil (Stephen J. Ying)
Date: 23 Aug 1994 00:58:43 GMT
Raw View
I'm trying to time my quicksort program by using the clock_t ADT as follows:

    float tps = 1e6;  //Using 1e6 ticks per sec as a guess

    clock_t start,end,ticksPerSecond = int(tps);

   start=clock();                  //start clock
   tempFile.quickSort(numLines);   //sort the lines
   end=clock();                    //stop clock

   cout << "\nSort time in seconds at " << ticksPerSecond;
   cout << " ticks per second = " << ((end-start)/tps) << endl;

The problem is that it returns the time in ticks and I need to convert into
seconds.  The Clocks_Per_Sec macro is not in the header libraries on my system.
I'm on a Sparc10.  Anyone know what I can do?



---
||||||||||||||||||||||||||||||||||||||
||                                  ||
|| Stephen J Ying                   ||
||                                  ||
|| Internet IP: ying@nps.navy.mil ||
||                                  ||
||||||||||||||||||||||||||||||||||||||