← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/dpath
  Run on Tue Jun 5 15:31:33 2012
Reported on Tue Jun 5 15:31:46 2012

Filename/home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/App/Rad/Help.pm
StatementsExecuted 27 statements in 2.61ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1118.54ms31.8msApp::Rad::Help::::BEGIN@2App::Rad::Help::BEGIN@2
555322µs322µsUNIVERSAL::::VERSION UNIVERSAL::VERSION (xsub)
132296µs96µsUNIVERSAL::::isa UNIVERSAL::isa (xsub)
42272µs72µsUNIVERSAL::::can UNIVERSAL::can (xsub)
32151µs51µsApp::Rad::Help::::register_helpApp::Rad::Help::register_help
11134µs1.01msApp::Rad::Help::::BEGIN@59App::Rad::Help::BEGIN@59
11130µs43µsApp::Rad::Help::::BEGIN@3App::Rad::Help::BEGIN@3
11127µs49µsApp::Rad::Help::::BEGIN@4App::Rad::Help::BEGIN@4
11126µs26µsUNIVERSAL::::Help UNIVERSAL::Help
11122µs116µsApp::Rad::Help::::loadApp::Rad::Help::load
0000s0sApp::Rad::Help::::helpApp::Rad::Help::help
0000s0sApp::Rad::Help::::helpstrApp::Rad::Help::helpstr
0000s0sApp::Rad::Help::::usageApp::Rad::Help::usage
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package App::Rad::Help;
22400µs231.8ms
# spent 31.8ms (8.54+23.3) within App::Rad::Help::BEGIN@2 which was called: # once (8.54ms+23.3ms) by App::Rad::BEGIN@3 at line 2
use Attribute::Handlers;
# spent 31.8ms making 1 call to App::Rad::Help::BEGIN@2 # spent 14µs making 1 call to Attribute::Handlers::import
3287µs256µs
# spent 43µs (30+13) within App::Rad::Help::BEGIN@3 which was called: # once (30µs+13µs) by App::Rad::BEGIN@3 at line 3
use strict;
# spent 43µs making 1 call to App::Rad::Help::BEGIN@3 # spent 13µs making 1 call to strict::import
421.39ms270µs
# spent 49µs (27+22) within App::Rad::Help::BEGIN@4 which was called: # once (27µs+22µs) by App::Rad::BEGIN@3 at line 4
use warnings;
# spent 49µs making 1 call to App::Rad::Help::BEGIN@4 # spent 22µs making 1 call to warnings::import
5
613µsour $VERSION = '0.03';
7
8
# spent 116µs (22+94) within App::Rad::Help::load which was called: # once (22µs+94µs) by App::Rad::_init at line 40 of App/Rad.pm
sub load {
914µs my ($self, $c) = @_;
10126µs194µs $c->register('help', \&help, 'show syntax and available commands');
# spent 94µs making 1 call to App::Rad::register
11}
12
13# shows specific help commands
14# TODO: context specific help,
15# such as "myapp.pl help command"
16sub help {
17 my $c = shift;
18 return usage() . "\n\n" . helpstr($c);
19}
20
21sub usage {
22 return "Usage: $0 command [arguments]";
23}
24
25sub helpstr {
26 my $c = shift;
27
28 my $string = "Available Commands:\n";
29
30 # get length of largest command name
31 my $len = 0;
32 foreach ( sort $c->commands() ) {
33 $len = length($_) if (length($_) > $len);
34 }
35
36 # format help string
37 foreach ( sort $c->commands() ) {
38 $string .= sprintf " %-*s\t%s\n", $len, $_,
39 defined ($c->{'_commands'}->{$_}->{'help'})
40 ? $c->{'_commands'}->{$_}->{'help'}
41 : ''
42 ;
43 ;
44 }
45 return $string;
46}
47
48
49{
5026µsmy %help_attr = ();
51
# spent 26µs within UNIVERSAL::Help which was called: # once (26µs+0s) by Attribute::Handlers::_apply_handler_AH_ at line 225 of Attribute/Handlers.pm
sub UNIVERSAL::Help :ATTR(CODE) {
5218µs my ($package, $symbol, $ref, $attr, $data, $phase, $filename, $linenum) = @_;
53
54119µs if ($package eq 'main') {
55 # If data is a single word, it is received as an array ref. Don't ask.
5611µs $data = join(' ', @$data) if ref($data) eq 'ARRAY';
5716µs $help_attr{ *{$symbol}{NAME} } = $data;
58 }
592582µs21.98ms
# spent 1.01ms (34µs+973µs) within App::Rad::Help::BEGIN@59 which was called: # once (34µs+973µs) by App::Rad::BEGIN@3 at line 59
}
# spent 1.01ms making 1 call to App::Rad::Help::BEGIN@59 # spent 973µs making 1 call to attributes::import
60
61
# spent 51µs within App::Rad::Help::register_help which was called 3 times, avg 17µs/call: # 2 times (34µs+0s) by App::Rad::register_commands at line 252 of App/Rad.pm, avg 17µs/call # once (16µs+0s) by App::Rad::register at line 306 of App/Rad.pm
sub register_help {
62312µs my ($self, $c, $cmd, $helptext) = @_;
63
64310µs if ((not defined $helptext) && (defined $help_attr{$cmd})) {
65 $helptext = $help_attr{$cmd};
66 }
67
68 # we do $helptext // undef as it would issue a warning otherwise
69346µs $c->{'_commands'}->{$cmd}->{'help'} = defined $helptext
70 ? $helptext
71 : undef
72 ;
73}
74
75}
76114µs42;
77__END__
 
# spent 322µs within UNIVERSAL::VERSION which was called 5 times, avg 64µs/call: # once (76µs+0s) by Exception::Class::Base::BEGIN@10 at line 10 of Exception/Class/Base.pm # once (69µs+0s) by Data::OptList::BEGIN@11 at line 11 of Data/OptList.pm # once (65µs+0s) by Data::DPath::Path::BEGIN@17 at line 17 of Data/DPath/Path.pm # once (61µs+0s) by Sub::Exporter::BEGIN@9 at line 9 of Sub/Exporter.pm # once (52µs+0s) by Exporter::Heavy::heavy_export at line 120 of Exporter/Heavy.pm
sub UNIVERSAL::VERSION; # xsub
# spent 72µs within UNIVERSAL::can which was called 4 times, avg 18µs/call: # 3 times (62µs+0s) by attributes::import at line 50 of attributes.pm, avg 21µs/call # once (11µs+0s) by Attribute::Handlers::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/5.14.1/Attribute/Handlers.pm:195] at line 171 of Attribute/Handlers.pm
sub UNIVERSAL::can; # xsub
# spent 96µs within UNIVERSAL::isa which was called 13 times, avg 7µs/call: # 10 times (77µs+0s) by base::import at line 74 of base.pm, avg 8µs/call # 3 times (19µs+0s) by Exception::Class::_make_subclass at line 152 of Exception/Class.pm, avg 6µs/call
sub UNIVERSAL::isa; # xsub