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
|
|
469
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
6
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.903'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use parent 'HTTP::AnyUA::Middleware'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
43
|
use Time::HiRes; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub request { |
16
|
2
|
|
|
2
|
1
|
18
|
my $self = shift; |
17
|
2
|
|
|
|
|
4
|
my ($method, $url, $args) = @_; |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
|
|
26
|
my $start = [Time::HiRes::gettimeofday]; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
9
|
my $resp = $self->backend->request($method, $url, $args); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $handle_response = sub { |
24
|
2
|
|
|
2
|
|
98
|
my $resp = shift; |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
7
|
$resp->{runtime} = sprintf('%.6f', Time::HiRes::tv_interval($start)); |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
57
|
return $resp; |
29
|
2
|
|
|
|
|
40
|
}; |
30
|
|
|
|
|
|
|
|
31
|
2
|
100
|
|
|
|
6
|
if ($self->response_is_future) { |
32
|
1
|
|
|
|
|
16
|
$resp = $resp->transform( |
33
|
|
|
|
|
|
|
done => $handle_response, |
34
|
|
|
|
|
|
|
fail => $handle_response, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
1
|
|
|
|
|
6
|
$resp = $handle_response->($resp); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
74
|
return $resp; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |