line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Goo::Thing::pm::Perl5Profiler; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Nigel Hamilton |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2004 |
7
|
|
|
|
|
|
|
# All Rights Reserved |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
10
|
|
|
|
|
|
|
# Filename: Perl5Profiler.pm |
11
|
|
|
|
|
|
|
# Description: Create a synopsis of a program / module / script |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Date Change |
14
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
# 01/11/2004 Auto generated file |
16
|
|
|
|
|
|
|
# 01/11/2004 Needed to work with the Goo |
17
|
|
|
|
|
|
|
# 16/02/2005 Need to find out a range of lines for things |
18
|
|
|
|
|
|
|
# 12/08/2005 Added method: getOption |
19
|
|
|
|
|
|
|
# 12/08/2005 Added method: testingNow |
20
|
|
|
|
|
|
|
# 24/08/2005 Added method: showHeader |
21
|
|
|
|
|
|
|
# |
22
|
|
|
|
|
|
|
############################################################################### |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
5
|
use Goo::Object; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
21
|
|
27
|
1
|
|
|
1
|
|
6
|
use Goo::Profile; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
20
|
|
28
|
1
|
|
|
1
|
|
5
|
use Goo::Prompter; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
22
|
|
29
|
1
|
|
|
1
|
|
7
|
use Text::FormatTable; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
30
|
1
|
|
|
1
|
|
753
|
use Goo::Thing::pm::Perl5ModuleInspector; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
1
|
|
7
|
use base qw(Goo::Object); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
369
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
############################################################################### |
36
|
|
|
|
|
|
|
# |
37
|
|
|
|
|
|
|
# get_methods_table - return a table of methods |
38
|
|
|
|
|
|
|
# |
39
|
|
|
|
|
|
|
############################################################################### |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub get_methods_table { |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
0
|
1
|
|
my ($this, $profile, $inspector, $thing) = @_; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $table = Text::FormatTable->new('4l 20l 77l'); |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
$table->head('', 'Methods', 'Description'); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
$table->rule('-'); |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
foreach my $method ($inspector->get_methods()) { |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $index_key = $profile->get_next_index_key(); |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$profile->add_option($index_key, $method, "Goo::Thing::pm::MethodProfileOption"); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# print "addin conter === $counter \n"; |
58
|
0
|
|
|
|
|
|
$table->row("[$index_key]", $method, $inspector->get_method_description($method)); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return Goo::Prompter::highlight_options($table->render()); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
############################################################################### |
68
|
|
|
|
|
|
|
# |
69
|
|
|
|
|
|
|
# run - generate a profile of a program |
70
|
|
|
|
|
|
|
# |
71
|
|
|
|
|
|
|
############################################################################### |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub run { |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
0
|
1
|
|
my ($this, $thing) = @_; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $profile = Goo::Profile->new($thing); |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
while (1) { |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$profile->clear(); |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
$profile->show_header("Perl5 Profile", $thing->get_filename(), $thing->get_location()); |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my $inspector = Goo::Thing::pm::Perl5ModuleInspector->new($thing->get_full_path()); |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my @packages = $inspector->get_uses_list(); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# add the module list |
90
|
0
|
|
|
|
|
|
$profile->add_options_table("Uses Packages", |
91
|
|
|
|
|
|
|
4, |
92
|
|
|
|
|
|
|
"Goo::Thing::pm::PackageProfileOption", |
93
|
|
|
|
|
|
|
$inspector->get_uses_list()); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# add the methods list |
96
|
0
|
|
|
|
|
|
$profile->add_options_table("Methods", 4, |
97
|
|
|
|
|
|
|
"Goo::Thing::pm::MethodProfileOption", |
98
|
|
|
|
|
|
|
$inspector->get_methods()); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# render a table of method signatures and descriptions |
101
|
|
|
|
|
|
|
#$profile->add_rendered_table($this->get_methods_table($profile, $inspector, $thing)); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# add a list of Things found in this Thing |
104
|
0
|
|
|
|
|
|
$profile->add_things_table(); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# show the profile and all the rendered tables |
107
|
0
|
|
|
|
|
|
$profile->display(); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# prompt the user for the next command |
110
|
0
|
|
|
|
|
|
$profile->get_command(); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
__END__ |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 NAME |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Goo::Thing::pm::Perl5Profiler - Create a synopsis of a Perl5 program |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 SYNOPSIS |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
use Goo::Thing::pm::Perl5Profiler; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 DESCRIPTION |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 METHODS |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=over |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item get_methods_table |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
return a table of methods |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item run |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
display a profile of a program |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=back |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 AUTHOR |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 SEE ALSO |
154
|
|
|
|
|
|
|
|