(foreign-declare "#include ") (define realtime-microsecs (foreign-lambda* double () "uint64_t time = clock_gettime_nsec_np(CLOCK_UPTIME_RAW); return( ((double) time) / 1000.0 );")) #| (foreign-declare "#include ") (define realtime-microsecs) (let ((%factor (the (or float boolean) #f))) ; (define %calc-time (foreign-lambda* double () "uint64_t time = mach_absolute_time(); return( ((double) time) / 1000.0 );")) ; (define %calc-factor (foreign-lambda* double () "mach_timebase_info_data_t info; mach_timebase_info( &info ); return( ((double) info.numer) / ((double) info.denom) );")) ; (set! realtime-microsecs (lambda () (* (%calc-time) %factor))) ; ;we immediatly determine the factor ;it should not change as long as the machine runs (set! %factor (%calc-factor)) (when (< %factor 0.0) (error 'macosx-realtime-microsecs "cannot determine scale factor") ) ) |#