in reply to •Re: Print the oldest file in a directory.
in thread Print the oldest file in a directory.
Please keep in mind, this is the first time I have ever used an ST. It is pretty much copied directly from http://www.5sigma.com/perl/schwtr.html.
Here is the benchmark code I used to test it with the results. The directory had 16,108 files in it. Let me know what you think.
#!/usr/bin/perl -w use strict; use Benchmark; timethese(100, { 'chad' => \&chad, 'swartz' => \&st,}); sub chad { sort{ (-M $b) <=> (-M $a) } glob("*"); } sub st { map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [$_, -M] } glob('*'); }
Here are the results of the benchmark:
Benchmark: timing 100 iterations of chad, swartz... chad: 118 wallclock secs (56.91 usr + 47.25 sys = 104.16 CPU) @ + 0.96/s (n=100) swartz: 1515 wallclock secs (142.33 usr + 1044.36 sys = 1186.69 CP +U) @ 0.08/s (n=100)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Re: Print the oldest file in a directory.
by merlyn (Sage) on Oct 31, 2002 at 03:41 UTC | |
by gnu@perl (Pilgrim) on Oct 31, 2002 at 16:02 UTC | |
|
Re: Re: Print the oldest file in a directory.
by runrig (Abbot) on Oct 31, 2002 at 00:46 UTC |