(foreign-declare "#include ") (define realtime-microsecs) (let ((%factor (the (or float boolean) #f))) ; (define %calc-time (foreign-lambda* double () "LARGE_INTEGER li; if( !QueryPerformanceCounter( &li ) ) return( -1.0 ); return( ((double) li.QuadPart) );")) ; (define %calc-factor (foreign-lambda* double () "LARGE_INTEGER li; if( !QueryPerformanceFrequency( &li ) ) return( -1.0 ); return( ((double) li.QuadPart) / 1000000.0 );")) ; (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 'windows-realtime-microsecs "cannot determine scale factor") ) )