(foreign-declare "#include ") (define get-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) / 1e6 );")) ; (set! get-microsecs (lambda () (* (%calc-time) %factor))) ; ;we immediatly determine the factor ;it should not change as long as the machine runs (set! %factor (%calc-factor)) (unless (positive? %factor) (error 'get-microsecs "cannot determine scale factor" %factor) ) )