JuliaLang / Microbenchmarks

Microbenchmarks comparing the Julia Programming language with other languages
https://julialang.org/benchmarks/
Other
87 stars 48 forks source link

Update 'print_to_file' Fortran benchmark #70

Open gha3mi opened 2 years ago

gha3mi commented 2 years ago

The use of implied DO-loops leads to a better performance, see link.

zoziha commented 2 years ago

Yes, an implicit do loop (for perf.f90) is more efficient:

subroutine printfd(n)
integer, intent(in) :: n
integer :: i
character(*), parameter :: newline = new_line("")
open(unit=1, file="/dev/null")
write(unit=1, fmt=*) (i, i+1, newline, i=1, n)
close(unit=1)
end subroutine

newline is a carriage return. Maybe we can create a PR for this.

gha3mi commented 2 years ago

Thanks @zoziha. I have checked your version with gfortran and ifort. Could you please create a PR?

Using GNU Fortran (GCC) 12.1.0: gfortran perf.f90 Previous Version New Version
23.536152 9.529248
Using ifort (IFORT) 2021.5.0 20211109: ifort perf.f90 Previous Version New Version
31.675000 14.640000
zoziha commented 2 years ago

But I'm not sure if using an implicit do loop is "cheating"? Other languages ​​use the usual for loop.