| 1 | package HTTP::Engine::Middleware::Profile::Runtime; | ||||||||||
| 2 | 1 | ▶ | use Any::Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | with 'HTTP::Engine::Middleware::Profile::Role'; | |||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use Time::HiRes qw(time); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | has 'start_time' => ( is => 'rw' ); | |||||||||
| 8 | 1 | has 'end_time' => ( is => 'rw' ); | |||||||||
| 9 | 1 | has 'send_header' => ( | |||||||||
| 10 | is => 'rw', | ||||||||||
| 11 | default => 0, | ||||||||||
| 12 | ); | ||||||||||
| 13 | 1 | has 'header_name' => ( | |||||||||
| 14 | is => 'rw', | ||||||||||
| 15 | default => 'X-Runtime', | ||||||||||
| 16 | ); | ||||||||||
| 17 | |||||||||||
| 18 | |||||||||||
| 19 | sub start { | ||||||||||
| 20 | 1 | ▶ | shift->start_time( time() ); | ||||||||
|
Subroutine
start: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | sub end { | ||||||||||
| 24 | 1 | ▶ | shift->end_time( time() ); | ||||||||
|
Subroutine
end: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | sub report { | ||||||||||
| 28 | 1 | ▶ | my($self, $c, $profile, $req, $res) = @_; | ||||||||
|
Subroutine
report: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 29 | |||||||||||
| 30 | 1 | my $elapsed = $self->end_time - $self->start_time; | |||||||||
| 31 | 1 | my $message = "Request handling execution time: $elapsed secs\n"; | |||||||||
| 32 | 1 | $profile->log( $message ); | |||||||||
| 33 | |||||||||||
| 34 | 1 | ▶ | return unless $self->send_header; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 1 | $res->header( $self->header_name => $elapsed ); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 1 | __PACKAGE__->meta->make_immutable;1; | |||||||||