#include #include int main(void) { timebasestruct_t start, finish; int val = 3; int secs, n_secs; /* get the time before the operation begins */ read_real_time(&start, TIMEBASE_SZ); /* begin code to be timed */ (void) printf("This is a sample line %d \n", val); /* end code to be timed */ /* get the time after the operation is complete */ read_real_time(&finish, TIMEBASE_SZ); /* * Call the conversion routines unconditionally, to ensure * that both values are in seconds and nanoseconds regardless * of the hardware platform. */ time_base_to_time(&start, TIMEBASE_SZ); time_base_to_time(&finish, TIMEBASE_SZ); /* subtract the starting time from the ending time */ secs = finish.tb_high - start.tb_high; n_secs = finish.tb_low - start.tb_low; /* * If there was a carry from low-order to high-order during * the measurement, we may have to undo it. */ if (n_secs < 0) { secs--; n_secs += 1000000000; } (void) printf("Sample time was %d seconds %d nanoseconds\n", secs, n_secs); exit(0); }