Cache-Profile
view release on metacpan or search on metacpan
lib/Cache/Profile.pm view on Meta::CPAN
$self->cache->$method(@_);
}
sub isa {
my ( $self, $class ) = @_;
$self->SUPER::isa($class) or $self->cache->isa($class);
}
my @timer_names = qw(hit get set miss);
sub timer_names { @timer_names }
foreach my $method ( "all", @timer_names ) {
my $count = "call_count_$method";
has $count => (
traits => [qw(Counter)],
isa => "Num",
is => "ro",
default => sub { 0 },
handles => {
"_inc_call_count_$method" => "inc",
"reset_call_count_$method" => [ set => 0 ],
lib/Cache/Profile.pm view on Meta::CPAN
time_r => tv_interval($start_r, $end_r),
},
);
return wantarray ? @ret : $ret[0];
}
sub reset {
my $self = shift;
foreach my $method ( $self->timer_names ) {
foreach my $measure ( qw(real cpu) ) {
$self->${\"reset_${method}_${measure}"};
}
$self->${\"reset_call_count_$method"};
}
$self->reset_hit_count;
$self->reset_miss_count;
}
lib/Cache/Profile.pm view on Meta::CPAN
sub report {
my $self = shift;
my $report = "";
if ( $self->hit_count ) {
$report .= sprintf "Hit rate: %0.2f%% (%d/%d)\n", ( $self->hit_rate * 100 ), $self->hit_count, $self->query_count;
}
foreach my $method ( $self->timer_names, "all" ) {
if ( my $calls = $self->${\"call_count_$method"} ) {
my %times;
foreach my $measure ( qw(real cpu) ) {
$times{$measure} = $self->${\"total_${measure}_time_${method}"};
}
$report .= sprintf "% 3s: %d time(s), %.2fs cpu, %0.2fs real\n", $method, $calls, @times{qw(cpu real)};
}
}
lib/Cache/Profile.pm view on Meta::CPAN
Returns the actual time elapsed using caching divided the estimated time to
compute all values (based on the average time to compute cache misses).
Smaller is better.
If the overhead of C<get> and C<set> is higher, this will be bigger than 1.
=item reset
Resets the counters/timers.
=back
=head1 SUPPORT
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Cache-Profile>
(or L<bug-Cache-Profile@rt.cpan.org|mailto:bug-Cache-Profile@rt.cpan.org>).
=head1 AUTHOR
( run in 1.133 second using v1.01-cache-2.11-cpan-49f99fa48dc )