line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::Debug::LWP; |
2
|
|
|
|
|
|
|
$Plack::Middleware::Debug::LWP::VERSION = '0.1'; |
3
|
1
|
|
|
1
|
|
14328
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
475
|
use LWPx::Profile; |
|
1
|
|
|
|
|
36801
|
|
|
1
|
|
|
|
|
28
|
|
7
|
1
|
|
|
1
|
|
455
|
use parent qw(Plack::Middleware::Debug::Base); |
|
1
|
|
|
|
|
230
|
|
|
1
|
|
|
|
|
4
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Plack::Middleware::Debug::LWP - LWP Profiling Panel |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
version 0.1 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
enable 'Debug::LWP'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
This module provides a panel for the L that gives |
24
|
|
|
|
|
|
|
profiling information for L requests. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub run { |
31
|
0
|
|
|
0
|
1
|
|
my($self, $env, $panel) = @_; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
LWPx::Profile::start_profiling(); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
return sub { |
36
|
0
|
|
|
0
|
|
|
my $res = shift; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $profile = LWPx::Profile::stop_profiling(); |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my @lines; |
41
|
0
|
|
|
|
|
|
my ($time, $requests); |
42
|
0
|
|
|
|
|
|
while (my ($req, $stats) = each %$profile) { |
43
|
0
|
|
|
|
|
|
my ($short_req) = $req =~ m/^(.*?)\n/s; |
44
|
0
|
|
|
|
|
|
my $summary = sprintf("%.5f/%d (%.5f avg)", $stats->{total_duration}, $stats->{count}, $stats->{total_duration} / $stats->{count}); |
45
|
0
|
|
|
|
|
|
push(@lines, $req, $summary); |
46
|
0
|
|
|
|
|
|
$requests += $stats->{count}; |
47
|
0
|
|
|
|
|
|
$time += $stats->{total_duration}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $summary = sprintf("%d requests / %.2f seconds", $requests, $time); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$panel->nav_title("LWP Requests"); |
53
|
0
|
|
|
|
|
|
$panel->title("LWP Requests ($summary)"); |
54
|
0
|
|
|
|
|
|
$panel->nav_subtitle($summary); |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$panel->content( |
57
|
|
|
|
|
|
|
$self->render_list_pairs(\@lines) |
58
|
|
|
|
|
|
|
); |
59
|
0
|
|
|
|
|
|
}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 TODO |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=over 2 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item * |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
The docs are pretty middling at the moment. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=back |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 AUTHORS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Chris Reinhardt |
77
|
|
|
|
|
|
|
crein@cpan.org |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Mark Ng |
80
|
|
|
|
|
|
|
cpan@markng.co.uk |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 COPYRIGHT |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This program is free software; you can redistribute |
85
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
The full text of the license can be found in the |
88
|
|
|
|
|
|
|
LICENSE file included with this module. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 SEE ALSO |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
L, L, L, perl(1) |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
__END__ |