On Fri, 8 Jun 2001, Richard Hulse wrote: > Since someone raised the general question of differences, which is faster? > my @result = <*.jpg>; > or variations on: > @files = grep /jpg/i, readdir DIR; use Benchmark; timethese(10000, { 'Glob' => sub { my @result = <*.jpg>; }, 'Read' => sub { opendir(DIR,"."); @files = grep /jpg/i, readdir DIR; }, }); Benchmark: timing 10000 iterations of Glob, Read... Glob: 78 wallclock secs (49.36 usr + 27.43 sys = 76.79 CPU) @ 130.23/s (n=10000) Read: 32 wallclock secs (27.71 usr + 3.69 sys = 31.40 CPU) @ 318.47/s (n=10000) Looks like readdir() is the winner, at least on my system. This was done in a directory of 1000 jpg images. The times certianly look right... the glob uses a ton of system time, and the readdir uses a ton of user time, just as one would expect. -- Ian
- Re: directory listing to array Evan McNabb
- Re: directory listing to array Paul
- Re: directory listing to array Jean-Matthieu Guerin
- RE: directory listing to array John Storms
- Re: directory listing to array Shawn
- Re: directory listing to array Pete Emerson
- Re: directory listing to array Shawn
- Re: directory listing to array Jeff 'japhy' Pinyan
- Re: directory listing to array Peter Scott
- Re: directory listing to array Richard Hulse
- Re: directory listing to ar... iansmith
- Re: directory listing to ar... Randal L. Schwartz
- Re: directory listing to ar... iansmith
- Re: directory listing to array Michael Fowler
- RE: directory listing to array Andrew Nelson
- RE: directory listing to array Peter Cornelius
- RE: directory listing to array Richard Hulse
- RE: directory listing to array Peter Cornelius
- RE: directory listing to array iansmith
- RE: directory listing to array Peter Cornelius