[Fortran] 纯文本查看 复制代码
call cpu_time(start_time)
do i = 1, array_size
res_array1(i) = array1(i) + array2(i)
res_array1(i) = array1(i) * array2(i)
end do
call cpu_time(end_time)
write(*,*) "使用循环操作需要的时间:", (end_time - start_time)*1000, "毫秒"
call cpu_time(start_time)
res_array2 = array1 + array2
res_array2 = array1 * array2
call cpu_time(end_time)
write(*,*) "使用数组操作需要的时间:", (end_time - start_time)*1000, "毫秒"
[Fortran] 纯文本查看 复制代码
call cpu_time(start_time)
do i = 1, array_size
res_array1(i) = array1(i) * array2(i)
end do
call cpu_time(end_time)
write(*,*) "使用循环操作需要的时间:", (end_time - start_time)*1000, "毫秒"
call cpu_time(start_time)
res_array2 = array1 * array2
call cpu_time(end_time)
write(*,*) "使用数组操作需要的时间:", (end_time - start_time)*1000, "毫秒"