Download c source code

/*
 * Copyright 2021 Jeisson Hidalgo-Cespedes - Universidad de Costa Rica
 */

#include "common.h"

double calculate_elapsed_time(const struct timespec* start_time) {
  struct timespec finish_time;
  clock_gettime(/*clk_id*/CLOCK_MONOTONIC, &finish_time);
  return finish_time.tv_sec - start_time->tv_sec +
    (finish_time.tv_nsec - start_time->tv_nsec) * 1e-9;
}