hal@dtor.com (Hal Wine) writes: >At 16:16 96-06-03, Brad Cox wrote: >>At 1:02 PM -0500 03/06/96, Hal Wine wrote: >>>This means you should either: >>>a) do a chdir() to the supplied directory, then always do an opendir() >>>on the current directory (':' for Mac, '.' for unix/dos). Or, >>>b) always prepend the directory to the filename returned by readdir(). >>> >>>My hunch is (a) runs faster on the Mac (due to internals of the Mac >>>file system), and no slower on other file systems. >> >>No, according to Matthias, a) shouldn't run faster. He said MacPerl fully >>expands relative pathnames to absolute pathnames before doing anything with >>them. > >Well, I hate to disagree with Matthias, but (a) DOES run faster, and >works correctly, while (b) has bugs. Well, I'd hate to disagree with either Hal's facts or my opionions, so I'll just claim that *all* of us are right :-) >(See attached script) Here's the >timing for 10,000 stats of a directory where the path string is 223 >characters, and 7 levels deep (excluding volume name): > Perl 5.0.7r1m: > 194 seconds for full path stat > 120 seconds for relative stat > MacPerl 4.1.8: > 200 seconds for full path stat > 126 seconds for relative stat Cool! I speeded up Perl by 6E-4 seconds per stat() :-) >So, we see that using a full path is about 60% slower than relative directorie s. I think I can explain: GUSI converts each path name, absolute or relative, into an FSSpec (that's unavoidable). Then, under some conditions, it converts the FSSpec back to a path name (that's avoidable). However, this currently only happens for open(), and only with the MPW tool. So, what I said to Brad Cox last fall (and I *do* remember that I said it) was not very accurate for MacPerl4 then, and is somewhat less accurate for MacPerl5 now (path conversion constantly keeps changing a little). The performance impact is difficult to quantify in the general case: The path conversion sometimes calls FSMakeFSSpec and sometimes it calls GetCatInfo a few times instead. Performance depends on how deeply the path is nested. >Using a full path is limited to strings of less than 256 characters, Oops! you shouldn't be. >and, there are some wierd things that happen at the extremity of that >limit. In the attached script, the name of the final directory created >gets truncated, without any error notice, in both MacPerl 4 & 5. I'll look at this. >I'm not sure when the conversion from relative to full path occurs. This conversion was necessary for routines that call through to the original MPW counterparts. MPW a few years ago didn't respect current directories, so I had to convert between GUSI current directories and MPW ones. However, Perl 5 uses CWGUSI, which is more emancipated from the MPW library, and usually doesn't even call MPW open() anymore. Matthias ----- Matthias Neeracher <neeri@iis.ee.ethz.ch> http://www.iis.ee.ethz.ch/~neeri ``One shudders at the notion that the Internet could become the least common denominator -- where "decent" is defined by the Americans, and "politically correct" by the Chinese.'' -- Jacques Gaillot, Bishop of Partenia