Hello,

I am trying to time a section of code where records are processed. I have tried the following, which seems too simple to not work,

Code:
#include <ctime>

// to output row number
 int record_count = 0;
// time when processing starts
clock_t start_clock, finish_clock;
// process time for current compound
long unsigned int clocks_to_finish = 0;

while( ***process record*** ) {

   // increment record count
   record_count++;
   // record clock at start of record processing
   start_clock = clock();

   ***

   // record clock at end of record processing
   finish_clock = clock();
   // time to finish current record
   clocks_to_finish = finish_clock - start_clock;

   // print difference
  cout << record_count << " clocks to finish record = " << clocks_to_finish << endl;

 }
In most cases, clocks_to_finish is 0. In some cases it is 1. I know that clock() precision isn't great but this program processes 1700+ records in about 1 minute 15 seconds. There should be at least 0.3 seconds or so per record so I was hoping that it would be good enough to provide some information. It may be that there are a couple of records that are taking up allot of the total time and most of them are quite quick. Even so, I should still be able to see a large value for some records.

Is there a solution like GetTickCount() that would provide better precision (I am in Linux)? Is the problem my implementation?

Thanks,

LMHmedchem