Created
July 2, 2014 13:59
-
-
Save jonathan-beard/fa560cabba090bad733c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdlib> | |
#include <iostream> | |
#include <cstring> | |
#include <mach/mach.h> | |
#include <mach/mach_time.h> | |
int | |
main( int argc, char **argv ) | |
{ | |
auto curr_time( mach_absolute_time() ); | |
/** call this to get the conversion factor to nanoseconds **/ | |
static mach_timebase_info_data_t timebase_info; | |
std::memset( &timebase_info, 0x0, sizeof( mach_timebase_info_data_t ) ); | |
if( timebase_info.denom == 0 ) | |
{ | |
(void)mach_timebase_info( &timebase_info ); | |
} | |
double nano_seconds( (curr_time * (timebase_info.numer / timebase_info.denom)) ); | |
std::cout << nano_seconds << "\n"; | |
return( EXIT_FAILURE ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment