- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there really no built in VS tool to measure execution times?
I know of VTune but that's a little excessive for just wanting to know what my execution time is. Is there a way to obtain execution within VS2008?
Thanks
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The opsys can provide a timestamp when requested, so you can bracket your execution code with calls and compute the elapsed time (and, btw, WORD denotes a 2-byte integer):
[cpp]!TYPE T_SYSTEMTIME
!SEQUENCE
! integer(WORD) wYear ! knowns WORD
! integer(WORD) wMonth ! knowns WORD
! integer(WORD) wDayOfWeek ! knowns WORD
! integer(WORD) wDay ! knowns WORD
! integer(WORD) wHour ! knowns WORD
! integer(WORD) wMinute ! knowns WORD
! integer(WORD) wSecond ! knowns WORD
! integer(WORD) wMilliseconds ! knowns WORD
!END TYPE
TYPE(T_SYSTEMTIME) :: st
CALL GetLocalTime (st)
[/cpp]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't know of a built-in way in VS to do this, but standard Fortran has intrinsics such as CPU_TIME and SYSTEM_CLOCK that work for timing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use QueryPerformanceCounter and QueryPerformanceFrequency
You may find it easier if you place these into your own functions.
The IVF team chose to use T_LARGE_INTEGER instead of T_LARGE_INTEGER_R, the "_R" has the union with an integer(8) :: QuadPart.
function GetTickNow()
use kernel32
typeT_li_li_r
sequence
union
map
T_LARGE_INTEGER :: li
end map
map
T_LARGE_INTEGER_R :: li_r
end map
end union
end type hack
integer(8) :: GetTickNow
type(T_li_li_r) :: hack
QueryPerformanceCounter(hack%li)
GetTickNow = hack%li_r
end function GetTickNow
function GetTicksPerSecond()
use kernel32
typeT_li_li_r
sequence
union
map
T_LARGE_INTEGER :: li
end map
map
T_LARGE_INTEGER_R :: li_r
end map
end union
end type hack
integer(8) ::GetTicksPerSecond
type(T_li_li_r) :: hack
QueryPerformanceFrequency(hack%li)
GetTicksPerSecond = hack%li_r
end function GetTickNow
function GetElapseTime(Tick1, Tick2)
integer(8) :: Tick1, Tick2
REAL(8) :: GetElapseTime
GetElapseTime = DBLE(Tick2-Tick1) / DBLE(GetTicksPerSecond())
end function GetElapseTime
program yourProg
integer(8) :: Tick1, Tick2
real(8) :: Time_Sub1
...
Tick1 = GetTickNow()
call Sub1
Tick2 = GetTickNow()
Time_Sub1 = GetElapseTime(Tick1, Tick2)
...
You can clean-up the code and place into module
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! I think CPU_time should be the simplest solution for my needs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - stubaan
Thanks! I think CPU_time should be the simplest solution for my needs.
There is an easier way, using the SECNDS function, like this:
! ----------------------------------
! Time variables
real TpInit, TpVar
! Register the beginning
TpInit = SECNDS(0.0)
! Do whatever you need
...
! Register how long your processes had taken
TpVar= SECNDS(TpInit)
! ----------------------------------
But, if you are really looking to profile your application, you should usea resource like VTune.
Regards,
Roger

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page