DashProfiler
view release on metacpan or search on metacpan
lib/DashProfiler/Auto.pm view on Meta::CPAN
B<*> C<flush_hook> uses warn() to write out the profile data, then resets (discards) the data.
=cut
my $auto = DashProfiler->add_profile( auto => {
period_exclusive => 'other',
profile_as_text_args => {
separator => " > ",
},
flush_hook => sub {
my ($self, $dbi_profile_name) = @_;
warn $_ for $self->profile_as_text($dbi_profile_name);
return $self->reset_profile_data($dbi_profile_name);
},
});
=head2 Sample Periods
When the modle is loaded it creates the C<auto> profile and calls
$auto->start_sample_period();
It also defines an C<END> block which does
$auto->end_sample_period();
$auto->flush;
so the sample period runs from the time the module was loaded (typically when
the program started running) through to the time the program exits.
=cut
$auto->start_sample_period();
END {
$auto->end_sample_period();
$auto->flush;
}
=head2 Imported Samplers
Using DashProfile::Auto in a file like this:
use DashProfiler::Auto;
is almost identical to this:
use DashProfiler::Import auto_profiler => [ basename(__FILE__) ];
=cut
sub import {
my $class = shift;
croak "DashProfile::Auto doesn't support explicit imports"
if @_;
local $DashProfiler::Import::ExportLevel = $DashProfiler::Import::ExportLevel + 1;
my $caller_file = (caller)[1];
$caller_file =~ s:.*[/\\]::; # delete everything upto and including the last slash or backslash
$class->SUPER::import( auto_profiler => [ $caller_file ] );
}
1;
=head1 AUTHOR
DashProfiler by Tim Bunce, L<http://www.tim.bunce.name> and
L<http://blog.timbunce.org>
=head1 COPYRIGHT
The DashProfiler distribution is Copyright (c) 2007-2008 Tim Bunce. Ireland.
All rights reserved.
You may distribute under the terms of either the GNU General Public
License or the Artistic License, as specified in the Perl README file.
=cut
( run in 1.019 second using v1.01-cache-2.11-cpan-7f9471e7e0a )