commit e08cb870bb2bd1e2e74d488b851314fa88a96606 parent f48c203edfc61993069c2cca06ff6e69c54b1fa6 Author: Michael Savage <mikejsavage@gmail.com> Date: Thu Jan 19 00:05:47 +0200 Add darwin_time.h Diffstat:
darwin_time.h | | | 14 | ++++++++++++++ |
unix_time.h | | | 2 | +- |
diff --git a/darwin_time.h b/darwin_time.h @@ -0,0 +1,14 @@ +#pragma once + +#include <mach/mach_time.h> + +#include "intrinsics.h" + +inline double get_time() { + mach_timebase_info_data_t freq; + mach_timebase_info( &freq ); + + u64 ticks = mach_absolute_time(); + + return double( ticks ) * ( freq.numer / 1e9 ) * double( freq.denom ); +} diff --git a/unix_time.h b/unix_time.h @@ -6,5 +6,5 @@ inline double get_time() { struct timespec ts; clock_gettime( CLOCK_MONOTONIC, &ts ); - return double( ts.tv_sec ) + ts.tv_nsec / 1000000000.0; + return double( ts.tv_sec ) + ts.tv_nsec / 1e9; }