我需要对 fortran 程序的一部分进行基准测试,以了解和量化特定更改的影响(为了使代码更易于维护,我们希望使其更 OO,例如利用函数指针)。
我有一个循环多次调用相同的子例程来对有限元执行计算。我想看看使用函数指针而不是硬编码函数的影响。
do i=1,n_of_finite_elements
! Need to benchmark execution time of this code
end do
获取此类循环的执行时间并以 nic 方式对其进行格式化的简单方法是什么?
我需要对 fortran 程序的一部分进行基准测试,以了解和量化特定更改的影响(为了使代码更易于维护,我们希望使其更 OO,例如利用函数指针)。
我有一个循环多次调用相同的子例程来对有限元执行计算。我想看看使用函数指针而不是硬编码函数的影响。
do i=1,n_of_finite_elements
! Need to benchmark execution time of this code
end do
获取此类循环的执行时间并以 nic 方式对其进行格式化的简单方法是什么?
我有一个 github 项目,可以在https://github.com/jlokimlin/array_passing_performance.git测量传递各种数组的性能
它使用来自https://github.com/jlokimlin/cpu_timer.git的 CpuTimer 派生数据类型。
用法:
use, intrinsic :: iso_fortran_env, only: &
wp => REAL64, &
ip => INT32
use type_CpuTimer, only: &
CpuTimer
type (CpuTimer) :: timer
real (wp) :: wall_clock_time
real (wp) :: total_processor_time
integer (ip) :: units = 0 ! (optional argument) = 0 for seconds, or 1 for minutes, or 2 for hours
! Starting the timer
call timer%start()
do i = 1, n
!...some big calculation...
end do
! Stopping the timer
call timer%stop()
! Reading the time
wall_clock_time = timer%get_elapsed_time(units)
total_processor_time = timer%get_total_cpu_time(units)
! Write time stamp to standard output
call timer%print_time_stamp()
! Write compiler info to standard output
call timer%print_compiler_info()