On 4/10/07, John W. Krahn <[EMAIL PROTECTED]> wrote:
Igor Sutton Lopes wrote:
snip
>     return unless -M $_ < 3;

Why not just use the modified( '>3' ) rule?
snip

There doesn't seem to be a performance issue either way:
        Rate    rule explict
rule    450/s      --     -0%
explict 450/s      0%      --

#!/usr/bin/perl

use strict;
use warnings;

use Benchmark;
use File::Find::Rule;
use File::Spec;

my $basedir = "/home/cowens";

$a = 0;
$b = 0;

sub explict_wanted {
   # using -M is better than doing the calculation to obtain the difference
   # from now and three days ago.
   $a++ unless -M $_ < 3;
}

sub rule_wanted {
   $b++;
}

# we use the name '*' to remove the current directory.
my %subs = (
       explict => sub {
               File::Find::Rule->directory()->maxdepth(1)->name('*')
               ->exec(\&explict_wanted)->in($basedir);
       },
       rule => sub {
               File::Find::Rule->directory()->maxdepth(1)->name('*')
               ->modified('>3')->exec(\&rule_wanted)->in($basedir);
       }
);

Benchmark::cmpthese(-5, \%subs);

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to