Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 657880fc85
Fetching contributors…

Cannot retrieve contributors at this time

51 lines (34 sloc) 0.894 kB
package Angelos::Middleware::Profile;
use Angelos::Class;
use Time::HiRes qw(time);
extends 'Angelos::Middleware';
sub wrap {
my ( $self, $next ) = @_;
sub {
my $req = shift;
my $res = $self->profile( $next, $req );
$res;
}
}
sub profile {
my ( $self, $code, $args ) = @_;
my $start_time = time();
my $result = $code->($args);
my $end_time = time();
my $elapsed = $end_time - $start_time;
my $message = "Request handling time: \n" . $elapsed . " secs";
$self->log( level => 'info', message => $message );
$result;
}
__END_OF_CLASS__
__END__
=head1 NAME
=head1 SYNOPSIS
=head1 DESCRIPTION
=head1 AUTHOR
Takatoshi Kitano E<lt>kitano.tk@gmail.comE<gt>
=head1 SEE ALSO
=head1 LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
Jump to Line
Something went wrong with that request. Please try again.