An illustrative code example in F90 using the performance timer API is shown below (and is also available in the examples directory from a top-level install). This example illustrates basic timer usage.
program main
use grvy
implicit none
integer :: Foo_Sleep = 1
integer :: Bar_Sleep = 2
integer :: Boo_Sleep = 3
integer :: Max_Iters = 2
integer :: i
real*8 :: igot,igot2
character :: timestring*50 = ''
call grvy_asci_time(timestring)
write(*,'(a,a26)') 'Run on: ',trim(timestring)
do i = 1,max_iters
print*,'Main iteration loop = ',i
call foo(foo_sleep)
print*,'Elapsed time since global init is: ',igot
call bar(bar_sleep)
call boo(boo_sleep)
enddo
print*,' '
print*,'Expecting ',max_iters*(foo_sleep+boo_sleep+bar_sleep),' secs '
call sleep(1)
print*,' '
print*,'Measured ',igot2-igot,' secs (expected approximately 1.0)'
print*,' '
print*,'The total elapsed time since init is: ',igot
print*,' '
print*,'Query individual timers - should match summary'
print*,' '
print*,'Query individual timer stats - should match summary'
print*,' '
print*,'Query individual timers (inclusive values)'
print*,' '
print*,'Query individual timer stats (inclusive values for boo)'
stop
end program main
subroutine foo(isleep)
use grvy
integer isleep
call sleep(isleep);
return
end subroutine foo
subroutine bar(isleep)
use grvy
integer isleep
call sleep(isleep);
return
end subroutine bar
subroutine boo(isleep)
use grvy
integer isleep
call sleep(isleep);
return
end subroutine boo
void grvy_timer_init(const char *description)
Initialize timer library with a description string which initiates the global timing process (the des...
void grvy_timer_end(const char *id)
Identify end of code section to time with a matching id string.
double grvy_timer_stats_variance_inc(const char *id)
Returns the variance (inclusive) for defined timer id.
void grvy_timer_summarize()
Print a concise summary of all defined timers to stdout. This routine shows the relative runtime perc...
double grvy_timer_stats_max_inc(const char *id)
Returns the largest (inclusive) measured timing (in seconds) for defined timer id.
double grvy_timer_stats_max(const char *id)
Returns the largest (exclusive) measured timing (in seconds) for defined timer id.
void grvy_timer_finalize()
Finalize global timing process - stops the active global timer.
double grvy_timer()
Basic wallclock timer which provides the time since epoch in seconds.
double grvy_timer_elapsed_global()
Returns total elapsed time (in seconds) for the global timer.
double grvy_timer_stats_mean(const char *id)
Returns the mean (exclusive) value (in seconds) for defined timer id.
int grvy_timer_save_hist(const char *experiment_name, const char *comment, int num_procs, const char *filename)
Save current libGRVY timing results to HDF file for logging.
double grvy_timer_stats_mean_inc(const char *id)
Returns the mean (inclusive) value (in seconds) for defined timer id.
void grvy_timer_begin(const char *id)
Identify beginning of code section to time with unique id string.
double grvy_timer_elapsedseconds(const char *id)
Returns total (exclusive) elapsed time (in seconds) for defined timer id.
double grvy_timer_stats_variance(const char *id)
Returns the variance (exclusive) for defined timer id.
double grvy_timer_stats_min(const char *id)
Returns the minimum (exclusive) measured timing (in seconds) for defined timer id.
double grvy_timer_elapsedseconds_inc(const char *id)
Returns total (inclusive) elapsed time (in seconds) for defined timer id.
int grvy_timer_stats_count(const char *id)
Returns the total number of timer calls for defined timer id.
double grvy_timer_stats_min_inc(const char *id)
Returns the minimum (inclusive) measured timing (in seconds) for defined timer id.