in reply to Re: request criticism web page with images in dir (File::Find File::Spec File::glob)
in thread request criticism web page with images in dir (File::Find File::Spec)

Perhaps even -
sub get_files { return sort { (stat($a))[9] <=> (stat($b))[9] } glob($_[0]."/*.{jpg,jpeg,png}") or die($_[0]." contained no images\n"); }
And if you're worried about speed, then the modulo operator is probably the least of your worries, as pretty much all operations are going to be costly (but if you were really looking for speed, then you'd be using C ;o) This should eliminate a lot of unncessary operations ie saving an array into memory but only using one element, and having to enter the size_cmp function for every comparison.
HTH

broquaint

  • Comment on Re: Re: request criticism web page with images in dir (File::Find File::Spec File::glob)
  • Select or Download Code

Replies are listed 'Best First'.
Re: request criticism web page with images in dir (File::Find File::Spec File::glob)
by mandog (Curate) on Sep 14, 2001 at 18:27 UTC
    I suspect that my code is I/O rather than CPU bound. Eleminating the unneeded map operation seemed to drop a wallclock second off the runtime. Moving from a 330Mhz PC w/ IDE drives to a 200Mhz with SCSI drives dropped another wallclock second.

    I think I could probabably eek out at least a few precious milliseconds by implimenting your suggestions, but if I really were concerned about speed I'd probably do more detailed benchmarking and look for the bottlenecks....

    Since my site gets maybe 20 vistitors on a busy day and I'm moving to a database backed approach and I need to spend time on other things (sigh).....

    btw, I'm not sure C is a speed win, even purely in terms of execution time. Programmer skill is much more highly corrilated with speed than language choice. (see paper by Lutz Prechelt

    Thanks again for all your help.



    --mandog