#include #include "concurrency.h" void walltime_start(walltime_t* start) { clock_gettime(CLOCK_MONOTONIC, start); } double walltime_elapsed_from(const walltime_t* start) { walltime_t finish; clock_gettime(CLOCK_MONOTONIC, &finish); return walltime_elapsed_between(start, &finish); } double walltime_elapsed_between(const walltime_t* start, const walltime_t* finish) { double elapsed = (finish->tv_sec - start->tv_sec); elapsed += (finish->tv_nsec - start->tv_nsec) / 1000000000.0; return elapsed; } long concurrency_cpu_count(void) { return sysconf(_SC_NPROCESSORS_ONLN); }