7 #ifndef MIGHTYMANDEL_WIN32
23 return (t1->tv_sec - t0->tv_sec) + (t1->tv_nsec - t0->tv_nsec) / 1000000000.0;
33 return calloc(1,
sizeof(
struct stopwatch));
37 clock_gettime(CLOCK_MONOTONIC, &t->
start);
41 clock_gettime(CLOCK_MONOTONIC, &t->
stop);
50 #include <mach/clock.h>
51 #include <mach/mach.h>
60 double time_difference(
const mach_timespec_t *t1,
const mach_timespec_t *t0) {
61 return (t1->tv_sec - t0->tv_sec) + (t1->tv_nsec - (double) t0->tv_nsec) / 1000000000.0;
65 mach_timespec_t
start;
71 return calloc(1,
sizeof(
struct stopwatch));
76 host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock);
77 clock_get_time(cclock, &t->
start);
78 mach_port_deallocate(mach_task_self(), cclock);
83 host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock);
84 clock_get_time(cclock, &t->
stop);
85 mach_port_deallocate(mach_task_self(), cclock);
105 double time_difference(
const LARGE_INTEGER *t1,
const LARGE_INTEGER *t0,
const LARGE_INTEGER *ticks) {
107 delta.QuadPart = t1->QuadPart - t0->QuadPart;
108 return delta.QuadPart / (double) ticks->QuadPart;
120 QueryPerformanceFrequency(&t->ticks);
125 QueryPerformanceCounter(&t->
start);
129 QueryPerformanceCounter(&t->
stop);