csci5451/assignments/01/common.c

20 lines
438 B
C
Raw Normal View History

2023-09-23 05:04:06 +00:00
#define _POSIX_C_SOURCE 199309L
#include <stdio.h>
#include <time.h>
#include "common.h"
double monotonic_seconds() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ts.tv_sec + ts.tv_nsec * 1e-9;
}
/**
* @brief Output the seconds elapsed while execution.
*
* @param seconds Seconds spent on execution, excluding IO.
*/
void print_time(double const seconds) {
printf("Execution time: %0.04fs\n", seconds);
}