Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Finding oldest file in directory

by TomDLux (Vicar)
on Oct 18, 2004 at 18:45 UTC ( #400274=note: print w/replies, xml ) Need Help??


in reply to Finding oldest file in directory

If it never has more than 10 files, who cares? If it's fast enough, don't worry. if you need more speed, benchmark and profile.

Except that sorting N values involves N log N to N^2 comparisons, and if each comparison involves 2 stat, at 10 ms each, it does waste system resources. Schwartzian Transform - creating a hash which associates the stat time with the file name - involves only N stats, and would be economical.

If files are not going to change, keep a list of known files in a hash, and obtain a list of eligible files. If there are any new files, stat only the ones you don't already know about.

--
TTTATCGGTCGTTATATAGATGTTTGCA

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://400274]
help
Chatterbox?
[1nickt]: Life is weird. Just reading about the iPhone battery problems and saw: 'It’s like calling water “dihydrogen monoxide”'

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2016-12-06 14:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (105 votes). Check out past polls.