20 lines
438 B
C
20 lines
438 B
C
#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);
|
|
} |