Microsoft KB Archive/147754

= BUG: DTIME and ETIME Return Zero Under Windows 95 =

PSS ID Number: 147754

Article Last Modified on 11/3/1999

-

The information in this article applies to:


 * Microsoft Fortran PowerStation for Windows 95 and Windows NT 4.0

-



This article was previously published under Q147754



SYMPTOMS
The DTIME and ETIME functions incorrectly return zero for program execution and elapsed CPU time under Windows 95.



CAUSE
Windows 95 does not support the underlying Win32 API function calls accessed by these functions. This does not apply to Windows NT 3.51.



RESOLUTION
Use the TIMEF function to profile CPU timings under Windows 95.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION
The following program under Windows NT 3.51 produces the correct elapsed time results for DTIME and ETIME. The same code under Windows 95 causes zero to be returned as the result, while TIMEF works correctly under both operating systems.

Sample Code
C Compile options need: none

USE PORTLIB REAL(4) DT0, DT1, ET0, ET1, TIMER(2) REAL(8) ELAPSED_TIME

WRITE(*,*) 'Elapsed execution times...' WRITE(*,*)

DT0 = DTIME(TIMER) CALL SPEND_TIME DT1 = DTIME(TIMER)

WRITE(*, '(A14,F6.3,A8)') 'Using DTIME: ', DT1-DT0, 'seconds'

ET0 = ETIME(TIMER) CALL SPEND_TIME ET1 = ETIME(TIMER)

WRITE(*, '(A14,F6.3,A8)') 'Using ETIME: ', ET1-ET0, 'seconds' C Use the following code as a workaround under Windows 95 ELAPSED_TIME = TIMEF CALL SPEND_TIME ELAPSED_TIME = TIMEF

WRITE(*, '(A14,F6.3,A8)') 'Using TIMEF: ', ELAPSED_TIME, 'seconds'

END

SUBROUTINE SPEND_TIME INTEGER I, J     DO I = 1, 1000000 J = J**2 END DO     END SUBROUTINE

