line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::AnyUA::Middleware::Runtime; |
2
|
|
|
|
|
|
|
# ABSTRACT: Middleware to determine response time |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
470
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
6
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.904'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use parent 'HTTP::AnyUA::Middleware'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
41
|
use Time::HiRes; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub request { |
16
|
2
|
|
|
2
|
1
|
18
|
my $self = shift; |
17
|
2
|
|
|
|
|
5
|
my ($method, $url, $args) = @_; |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
|
|
26
|
my $start = [Time::HiRes::gettimeofday]; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
8
|
my $resp = $self->backend->request($method, $url, $args); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $handle_response = sub { |
24
|
2
|
|
|
2
|
|
95
|
my $resp = shift; |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
9
|
$resp->{runtime} = sprintf('%.6f', Time::HiRes::tv_interval($start)); |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
51
|
return $resp; |
29
|
2
|
|
|
|
|
34
|
}; |
30
|
|
|
|
|
|
|
|
31
|
2
|
100
|
|
|
|
4
|
if ($self->response_is_future) { |
32
|
1
|
|
|
|
|
15
|
$resp = $resp->transform( |
33
|
|
|
|
|
|
|
done => $handle_response, |
34
|
|
|
|
|
|
|
fail => $handle_response, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
1
|
|
|
|
|
5
|
$resp = $handle_response->($resp); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
76
|
return $resp; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |