* Helper function to calculate a time interval between two timestamps held in a struct timespec. */
| 79 | * Helper function to calculate a time interval between two timestamps held in a struct timespec. |
| 80 | */ |
| 81 | double duration(struct timespec start, struct timespec end) { |
| 82 | int secs = end.tv_sec - start.tv_sec; |
| 83 | int nsecs = (int) end.tv_nsec - (int) start.tv_nsec; |
| 84 | |
| 85 | if (nsecs < 0) { |
| 86 | nsecs += 1000000000; |
| 87 | secs--; |
| 88 | } |
| 89 | |
| 90 | return (double) secs + (double) nsecs / 1000000000; |
| 91 | } |
| 92 | |
| 93 | int main(int argc, char *argv[]) { |
| 94 | clockbound_ctx *ctx; |