mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-07 04:30:51 +08:00
Added timing support for Mac OS X
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
#include "timing.h"
|
#include "timing.h"
|
||||||
|
|
||||||
|
#ifdef __MACH__
|
||||||
|
#include <mach/clock.h>
|
||||||
|
#include <mach/mach.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
|
||||||
|
|
||||||
@@ -28,7 +33,19 @@ timespec diff(timespec start, timespec end);
|
|||||||
|
|
||||||
void getTime(timespec* time)
|
void getTime(timespec* time)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
|
||||||
|
clock_serv_t cclock;
|
||||||
|
mach_timespec_t mts;
|
||||||
|
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
||||||
|
clock_get_time(cclock, &mts);
|
||||||
|
mach_port_deallocate(mach_task_self(), cclock);
|
||||||
|
time->tv_sec = mts.tv_sec;
|
||||||
|
time->tv_nsec = mts.tv_nsec;
|
||||||
|
#else
|
||||||
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, time);
|
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, time);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
double diffclock(timespec time1,timespec time2)
|
double diffclock(timespec time1,timespec time2)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user