1 // Timing measurement utilities implementation.
13 gettimeofday(&t->tv, NULL);
22 // The clock_t type is an "arithmetic type", which could be
23 // integral, double, long double, or others.
25 // Add 0.0 to make it a double or long double, then divide (in
26 // double or long double), then convert to double for our purposes.
27 return (double) ((t->clock + 0.0) / CLOCKS_PER_SEC);
29 return (double) t->tv.tv_sec + ((double) t->tv.tv_usec) / 1000000.0;
37 return (double) ((clock() + 0.0) / CLOCKS_PER_SEC);
40 gettimeofday(&tv, NULL);
41 return (double) tv.tv_sec + ((double) tv.tv_usec) / 1000000.0;
51 // The clock_t type is an "arithmetic type", which could be
52 // integral, double, long double, or others.
54 // Subtract first, resulting in another clock_t, then add 0.0 to
55 // make it a double or long double, then divide (in double or long
56 // double), then convert to double for our purposes.
57 return (double) (((t2->clock - t1->clock) + 0.0) / CLOCKS_PER_SEC);
59 double const d2 = (double) t2->tv.tv_sec + ((double) t2->tv.tv_usec) / 1000000.0;
60 double const d1 = (double) t1->tv.tv_sec + ((double) t1->tv.tv_usec) / 1000000.0;