At 8:07 PM -0600 11/18/98, William H. Asquith wrote: } I'm building 20000 line arrays for some statistical research. I have } working algorithms in FORTRAN, which I'm running under MachTen 4.1. Speed } is reasonable for each build of the array. I'm excited about MacPerl and } decided yesterday to port the FORTRAN to MacPerl. Now the array builds much } slower. I've changed a DO (ie FOR) loop to a WHILE (supposed to be faster } from Programming Perl) and am PUSHing each element onto the array. This } speed things up a little bit, I think. You might be able to pick up some speed by preallocating the array. (Something like $#$betainverseref = 20000 might do it, but I'm not sure that syntax works properly with a reference. I suppose it should.) } } Basically, my question to all of you is: Should I expect MacPerl to run } slower than FORTRAN on MachTen? Seems amazing to me since I'd expect } working in the native MacOS to be faster than an emulated Unix. I wouldn't expect that at all. First, I'm not that familiar with MachTen but my understanding is that it's not an emulator at all, but real BSD Unix running in a MacOS box. Second, Fortran is still the premier language for numerical work for good reasons. Like all compiled languages I've ever used, a Fortran array is a "real" array (contiguous values are contiguous in memory). Fortran allocates the memory at startup. Perl arrays are not arrays in sense that C or Fortran arrays are; each Perl is a C structure (called an SV if memory serves; the details can be found at Gisle Aas' Perlguts Illustrated: <http://home.sol.no/~aas/perl/guts/>), and arrays are collections of SV's. There's probably some optimization going on, but as written each time through your loop Perl has to allocate memory (larger than 8 bytes) and put a value in the right slot. There's a Perl extension available from CPAN named PDL which is an attempt to teach Perl how to deal with "real" arrays. Be warned that of the three flavors of Unix I use regularly I've only gotten PDL to work on one of them (LinuxPPC), and only over the last weekend when I discovered that it would test clean if I turned egcs' optimizer off. It will not work under MacOS at all, I'd guess. (In any event to even attempt to get it to work you'd need both a C and Fortran compiler that will work together.) It may work under MachTen. It may or may not speed things up for you; I have very little experience actually using it. Personally I do some of my numerical work in Perl, but not when I'm worried about speed. If I was worried about speed, I'd use C or Fortran; Perl can certainly be no faster than a pre-compiled language, and is probably going to be slower. I use Perl mainly for postprocessing and graphics (using PGPLOT). } } Below is the salient code frag. } while( $i <= ($nF-1) ) { } # print STDOUT " BETAINVER i = $i\n"; } $x = $i*$dF; } $F = &BETAI($a,$b,$x); } if($F == -9999) { } $flag = -9999; } $betainverseref = ""; } return $betainverseref, $flag; } } } push(@$betainverseref, $F); } $i++; } } } return $betainverseref, $flag; } } Thanks, } -wha } ----- Paul J. Schinder schinder@pobox.com ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch