-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Srinath Vadlamani
committed
Jan 2, 2013
1 parent
f53d02e
commit f74f186
Showing
2 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
module IFWIN | ||
|
||
use ISO_C_BINDING | ||
|
||
implicit none | ||
|
||
private | ||
|
||
public QueryPerformanceCounter | ||
|
||
interface | ||
|
||
function QueryPerformanceCounter(lpPerformanceCount) & | ||
|
||
bind(C, name='QueryPerformanceCounter') | ||
|
||
import | ||
|
||
implicit none | ||
|
||
!gcc attributes stdcall :: QueryPerformanceCounter | ||
|
||
integer(C_INT) QueryPerformanceCounter | ||
|
||
integer(C_INT64_T) lpPerformanceCount | ||
|
||
end function QueryPerformanceCounter | ||
|
||
end interface | ||
|
||
public QueryPerformanceFrequency | ||
|
||
interface | ||
|
||
function QueryPerformanceFrequency(lpFrequency) & | ||
|
||
bind(C, name='QueryPerformanceFrequency') | ||
|
||
import | ||
|
||
implicit none | ||
|
||
!gcc attributes stdcall :: QueryPerformanceFrequency | ||
|
||
integer(C_INT) QueryPerformanceFrequency | ||
|
||
integer(C_INT64_T) lpFrequency | ||
|
||
end function QueryPerformanceFrequency | ||
|
||
end interface | ||
|
||
end module IFWIN | ||
program test | ||
|
||
use IFWIN | ||
|
||
use ISO_C_BINDING | ||
|
||
implicit none | ||
|
||
integer(C_INT64_T) lpFrequency, lpPerformanceCount | ||
|
||
integer(C_INT) ll | ||
ll = QueryPerformanceFrequency(lpFrequency) | ||
|
||
ll = QueryPerformanceCounter(lpPerformanceCount) | ||
|
||
write(*,*) lpFrequency, lpPerformanceCount | ||
|
||
end program test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
SUBROUTINE use_QueryPerform (elapse) | ||
! | ||
! Returns the total elapsed time in seconds | ||
! based on QueryPerformanceCounter | ||
! This is the fastest and most accurate timing routine | ||
! | ||
real*8, intent (out) :: elapse | ||
! | ||
STDCALL QUERYPERFORMANCECOUNTER 'QueryPerformanceCounter' (REF):LOGICAL*4 | ||
STDCALL QUERYPERFORMANCEFREQUENCY 'QueryPerformanceFrequency' (REF):LOGICAL*4 | ||
! | ||
real*8 :: freq = 1 | ||
logical*4 :: first = .true. | ||
integer*8 :: start = 0 | ||
integer*8 :: num | ||
logical*4 :: ll | ||
! | ||
! Calibrate this time using QueryPerformanceFrequency | ||
if (first) then | ||
num = 0 | ||
ll = QueryPerformanceFrequency (num) | ||
freq = 1.0d0 / dble (num) | ||
start = 0 | ||
ll = QueryPerformanceCounter (start) | ||
first = .false. | ||
end if | ||
! | ||
num = 0 | ||
ll = QueryPerformanceCounter (num) | ||
elapse = dble (num-start) * freq | ||
return | ||
end |