Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Why does my code run slow?

Name: Anonymous 2008-02-27 15:53

$ cat f1.f
      PROGRAM f
      implicit none

      integer H, I, J
      integer A(1024, 1024)

      do 10 H = 0, 30
         do 20 I = 1, 1024
            do 30 J = 1, 1024
               A(I,J) = 0
 30         continue
 20      continue
 10   continue

      end program f
$ time ./f1

real    0m3.086s
user    0m3.063s
sys    0m0.019s

$ cat f2.c
int main(void)
{
    int h, i, j, a[1024][1024];

    for (h = 0; h < 10; h++)
      for (i = 0; i < 1024; i++)
    for (j = 0; j < 1024; j++)
      a[i][j] = 0; // !!

    return 0;
  }

$ time ./f2

real    0m0.080s
user    0m0.072s
sys    0m0.008s

Why is the FORTRAN version almost as slow as Ruby, which is slow as fuck?

Name: Anonymous 2008-02-27 22:37

>>7
plz elaborate

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List