Silvio a Beccara a écrit:
But here is another example, this time both in Pascal and in Fortran:
<snip>
subroutine mmult ( rows, cols, m1, m2, mm )
integer r, c, rows, cols, i, j, k include 'size.h' integer m1( 0:size, 0:size ), m2( 0:size, 0:size ), mm ( 0:size, 0:size ), count, val
rows = rows - 1 cols = cols - 1
probably an untested last minute "improvement" ? in fortran all parameters are passed by reference, not by value, so the global rows and cols are decreased at each enter of the subroutines, particularly if you use num >1 to have more meaningfull timings
do i = 0, rows do j = 0, cols val = 0 do k = 0, cols val = val + m1(i,k)*m2(k, j) enddo mm(i, j) = val enddo enddo
return end
Anyway making the changes indicated by Walter in another mail, plus correcting this mistake, after checking that pascal and fortran programs give identical results, using a pentium4, djgpp in a W98 dos box gives (-march=pentium4 -O3) for 10000 iterations 0.88 seconds for fortan 0.93 seconds for pascal i.e. one clock tick difference One can analyze in more detail the reason of this difference (we have seen in this list a comparison between C and pascal where the issue was a different treatment of global variables) but the conclusion is already clear: no significant difference between execution times between languages, when they can have identical constructs like here. The reason to choose a computer language is not there. Why do you expect anything else ? computer science is not magics
Maurice